Skip to content

Commit 6176ea1

Browse files
authored
update README
1 parent de609e3 commit 6176ea1

File tree

1 file changed

+66
-15
lines changed

1 file changed

+66
-15
lines changed

README.rst

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
======================
1+
==================================================
22
Cookiecutter PyPackage Rust Cross-Platform Publish
3-
======================
3+
==================================================
44

5-
Cookiecutter_ template for a Python package with a Rust binary module.
5+
Cookiecutter_ template for building and releasing Python packages with a Rust binary module.
6+
Supports Linux, macOS and Windows.
67

78
Rust is a new systems programming language that is comparable in speed with C/C++;
89
but it also has lots of nice modern features like memory safety, a package manager,
@@ -14,19 +15,30 @@ A very important goal of the project is that it be able to produce a binary
1415
distribution (Wheel) which will not require the end user to actually compile
1516
the Rust code themselves.
1617

17-
An example output of this cookiecutter can be seen at rust_pypi_example_.
18+
A binary wheel is produced for Linux and OSX by TravisCI_. A windows wheel is built
19+
for Windows with appveyor_.
20+
21+
Example Output
22+
--------------
23+
24+
An exmple project made by this cookiecutter can be seen on github at mckaymatt/rust_pypi_example_.
1825
In the example I wrote a cli in Python that interops via CFFI with a Rust binary.
19-
I used a tool called setuptools-rust which enables setuptools to handle compiling
26+
I used a tool called PyO3/setuptools-rust_ which enables setuptools to handle compiling
2027
just like it would with C.
2128

22-
A binary wheel is produced for Linux and OSX by TravisCI_. A windows wheel is built
23-
for Windows with appveyor_.
29+
The binary wheels can be seen on Pypi at pypi.python.org/pypi/rust-pypi-example_.
30+
You should be able to install the package on your platform with::
2431

32+
pip install rust_pypi_example
33+
# test if a number is prime
34+
rust_pypi_example 13
35+
36+
Please create an issue_ if you encounter any problems and include details about your platform.
2537

2638
Supported platforms
27-
-----------------------------
39+
-------------------
2840
* manylinux_X86_64 and manylinux_i686
29-
* OSX
41+
* macOS/OSX
3042
* Windows
3143

3244
Features
@@ -42,7 +54,10 @@ Features
4254

4355
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
4456
.. _appveyor: https://www.appveyor.com/
45-
.. _rust_pypi_example: https://github.com/mckaymatt/rust_pypi_example
57+
.. _mckaymatt/rust_pypi_example: https://github.com/mckaymatt/rust_pypi_example
58+
.. _PyO3/setuptools-rust: https://github.com/PyO3/setuptools-rust
59+
.. _pypi.python.org/pypi/rust-pypi-example: https://pypi.python.org/pypi/rust-pypi-example
60+
.. _issue: https://github.com/mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish/issues/new
4661

4762
Quickstart
4863
----------
@@ -62,16 +77,36 @@ After you finish answering the promps, the new project will be made.
6277

6378
Local Development Workflow / Hello World
6479
----------------------------------------
65-
This depends on you having ``Make``, ``virtualenv``, and the Rust compiler. Get the Rust compiler from Rustup_
80+
This depends on you having ``virtualenv``, and the Rust compiler. Get the Rust compiler from Rustup_. Linux/macOS
81+
users will also need ``Make``.
6682

67-
I will also mention that the Makefile workflow doesn't quite work on Windows yet, but it's still pretty easy
68-
to get going. You basically make a virtualenv, install the dev dependencies and run ``python setup.py test|install|bdist_wheel|develop`` depending on what you want to do.
83+
**Linux/macOS**
6984

70-
Still with me? Okay, you are now ready to build your first Rust wheel locally.
71-
Go into the directory that Cookiecutter just created and perform your first build locally with:
85+
The entire local process of building and testing (including
86+
creating and activating a virtualenv) is conducted by a single Make command::
7287

88+
# cd to new project. The default name is rust_pypi_example
89+
cd rust_pypi_example
7390
make local-test
7491

92+
I will note that the virtualenv created by Make seems to have some issues if you try to activate it.
93+
If you want to work interactivly you should build your own virtualenv and use that instead.
94+
95+
**Windows**
96+
97+
The Makefile workflow doesn't quite work on Windows yet, but it's still pretty easy
98+
to get going. You basically make a virtualenv, install the dev dependencies and run ``python setup.py test|install|bdist_wheel|develop`` depending on what you want to do.
99+
100+
Go into the directory that Cookiecutter just created (default is rust_pypi_example) and perform your
101+
first build locally with::
102+
103+
# make a virtualenv and activate it
104+
pip install -U pip
105+
pip install -r requirements_dev.txt
106+
python setup.py build_ext # compile ext
107+
python setup.py test # test
108+
python setup.py bdist_wheel # to make the wheel. Always build_ext first
109+
75110
W00t. You just tested, compiled and packaged you're first Python wheel with a Rust module.
76111

77112
.. _Rustup: https://www.rustup.rs/
@@ -92,6 +127,22 @@ Set Up Cross-Platform CI, Build and Release
92127

93128
.. _`pip docs for requirements files`: https://pip.pypa.io/en/stable/user_guide/#requirements-files
94129

130+
Known Bugs
131+
----------
132+
If you don't run **build_ext** before **bdist_wheel**, the resulting wheel will not have the shared library
133+
compiled by Cargo. In other words::
134+
135+
# This alone will make a defective wheel
136+
python setup.py bdist_wheel
137+
138+
# this will work
139+
python setup.py build_ext
140+
python setup.py bdist_wheel
141+
142+
TODOs
143+
-----
144+
145+
[ ] source distributions.
95146

96147
For more details, see the `cookiecutter-pypackage tutorial`_.
97148

0 commit comments

Comments
 (0)