Skip to content

Commit df3bf6c

Browse files
authored
Merge pull request #164 from davidhewitt/use-myst
docs: use myst-parser
2 parents b9e10aa + 6807f79 commit df3bf6c

File tree

7 files changed

+83
-86
lines changed

7 files changed

+83
-86
lines changed

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```{include} ../README.md
2+
```

docs/README.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/building_wheels.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Building wheels
2+
3+
Because `setuptools_rust` is an extension to `setuptools`, the standard `setup.py bdist_wheel` command is used to build wheels which can be uploaded to pypy.
4+
5+
This doc suggests two ways to go about this.
6+
7+
## Using `cibuildwheel`
8+
9+
[`cibuildwheel`][cibuildwheel] is a tool to build wheels for multiple platforms using Github Actions.
10+
11+
The [`rtoml` package does this, for example](https://github.com/samuelcolvin/rtoml/blob/143ee0907bba616cbcd5cc58eefe9000fcc2b5f2/.github/workflows/ci.yml#L99-L195).
12+
13+
## Building manually
14+
15+
Place a script called `build-wheels.sh` with the following contents in your project root (next to the `setup.py` file):
16+
17+
```bash
18+
#!/bin/bash
19+
set -ex
20+
21+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
22+
export PATH="$HOME/.cargo/bin:$PATH"
23+
24+
cd /io
25+
26+
for PYBIN in /opt/python/cp{36,37,38,39}*/bin; do
27+
"${PYBIN}/pip" install -U setuptools wheel setuptools-rust
28+
"${PYBIN}/python" setup.py bdist_wheel
29+
done
30+
31+
for whl in dist/*.whl; do
32+
auditwheel repair "$whl" -w dist/
33+
done
34+
```
35+
36+
This script can be used to produce wheels for multiple Python versions.
37+
38+
### Binary wheels on linux
39+
40+
To build binary wheels on linux, you need to use the [manylinux docker container](https://github.com/pypa/manylinux). You also need a `build-wheels.sh` similar to [the one in the example](https://github.com/PyO3/setuptools-rust/blob/main/examples/html-py-ever/build-wheels.sh), which will be run in that container.
41+
42+
First, pull the `manylinux2014` Docker image:
43+
44+
```bash
45+
docker pull quay.io/pypa/manylinux2014_x86_64
46+
```
47+
48+
Then use the following command to build wheels for supported Python versions:
49+
50+
```bash
51+
docker run --rm -v `pwd`:/io quay.io/pypa/manylinux2014_x86_64 bash /io/build-wheels.sh
52+
```
53+
54+
This will create wheels in the `dist` directory:
55+
56+
```bash
57+
$ ls dist
58+
hello_rust-0.1.0-cp36-cp36m-linux_x86_64.whl hello_rust-0.1.0-cp36-cp36m-manylinux2014_x86_64.whl
59+
hello_rust-0.1.0-cp37-cp37m-linux_x86_64.whl hello_rust-0.1.0-cp37-cp37m-manylinux2014_x86_64.whl
60+
hello_rust-0.1.0-cp38-cp38-linux_x86_64.whl hello_rust-0.1.0-cp38-cp38-manylinux2014_x86_64.whl
61+
hello_rust-0.1.0-cp39-cp39-linux_x86_64.whl hello_rust-0.1.0-cp39-cp39-manylinux2014_x86_64.whl
62+
```
63+
64+
You can then upload the `manylinux2014` wheels to pypi using [twine](https://github.com/pypa/twine).
65+
66+
It is possible to use any of the `manylinux` docker images: `manylinux1`, `manylinux2010` or `manylinux2014`. (Just replace `manylinux2014` in the above instructions with the alternative version you wish to use.)
67+
68+
### Binary wheels on macOS
69+
70+
For building wheels on macOS it is sufficient to run the `bdist_wheel` command, i.e. `setup.py bdist_wheel`.
71+
72+
To build `universal2` wheels set the `ARCHFLAGS` environment variable to contain both `x86_64` and `arm64`, for example `ARCHFLAGS="-arch x86_64 -arch arm64"`. Wheel-building solutions such as [`cibuildwheel`][cibuildwheel] set this environment variable automatically.
73+
74+
[cibuildwheel]: https://github.com/pypa/cibuildwheel

docs/building_wheels.rst

Lines changed: 0 additions & 81 deletions
This file was deleted.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"sphinx.ext.autodoc",
2727
"sphinx.ext.napoleon",
2828
"sphinx_autodoc_typehints",
29-
"m2r2",
29+
"myst_parser",
3030
]
3131

3232
# Add any paths that contain templates here, relative to this directory.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
```{eval-rst}
12
.. toctree::
23
:maxdepth: 2
34
:hidden:
45
5-
README
6+
README.md
67
building_wheels
78
reference
9+
```
810

9-
.. include:: README.rst
11+
```{include} ../README.md
12+
```

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
m2r2==0.3.1
21
Sphinx==4.1.2
32
sphinx-autodoc-typehints==1.12.0
43
furo==2021.8.31
4+
myst-parser==0.15.2

0 commit comments

Comments
 (0)