Skip to content

Commit 63ee6e9

Browse files
authored
Merge pull request #213 from messense/cargo-zigbuild
Test cross compiling with cargo-zigbuild
2 parents 75a6bd8 + e13a825 commit 63ee6e9

File tree

3 files changed

+60
-13
lines changed

3 files changed

+60
-13
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
run: rustup target add aarch64-apple-darwin
9595

9696
- name: Install test dependencies
97-
run: pip install --upgrade tox setuptools
97+
run: pip install --upgrade tox
9898

9999
- name: Install wheel (workaround python 3.10 CI issue)
100100
if: matrix.python-version == '3.10-dev'
@@ -170,7 +170,7 @@ jobs:
170170
run: |
171171
cd examples/rust_with_cffi/
172172
python --version
173-
pip install -U pip wheel setuptools
173+
pip install -U wheel
174174
python setup.py bdist_wheel --py-limited-api=cp39
175175
ls -la dist/
176176
env:
@@ -188,7 +188,7 @@ jobs:
188188
shell: bash
189189
run: |
190190
cd examples/
191-
pip install -U pip wheel setuptools
191+
pip install -U wheel
192192
python --version
193193
pip install rust_with_cffi/dist/rust_with_cffi*.whl
194194
python -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
@@ -268,7 +268,56 @@ jobs:
268268
python -m pip install wheel
269269
python setup.py bdist_wheel --plat-name manylinux2014_aarch64
270270
ls -la dist/
271-
- uses: uraimo/[email protected]
271+
- uses: uraimo/[email protected]
272+
name: Install built wheel
273+
with:
274+
arch: aarch64
275+
distro: ubuntu20.04
276+
dockerRunArgs: |
277+
--volume "${PWD}/examples/namespace_package:/io"
278+
install: |
279+
apt-get update
280+
apt-get install -y --no-install-recommends python3 python3-pip
281+
pip3 install -U pip
282+
run: |
283+
pip3 install namespace_package --no-index --find-links /io/dist/ --force-reinstall
284+
python3 -c "from namespace_package import rust; assert rust.rust_func() == 14"
285+
python3 -c "from namespace_package import python; assert python.python_func() == 15"
286+
287+
test-zigbuild:
288+
runs-on: ubuntu-latest
289+
steps:
290+
- uses: actions/checkout@master
291+
- name: Setup python
292+
uses: actions/setup-python@v2
293+
with:
294+
python-version: 3.8
295+
- uses: actions-rs/toolchain@v1
296+
with:
297+
profile: minimal
298+
toolchain: stable
299+
target: aarch64-unknown-linux-gnu
300+
override: true
301+
- name: Install cargo-zigbuild
302+
run: |
303+
cargo install cargo-zigbuild
304+
python3 -m pip install ziglang
305+
- name: Build package
306+
run: pip install -e .
307+
- name: Build wheel using cargo-zigbuild
308+
shell: bash
309+
env:
310+
CARGO: cargo-zigbuild
311+
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
312+
PYO3_CROSS_LIB_DIR: /opt/python/cp38-cp38/lib
313+
run: |
314+
mkdir -p $PYO3_CROSS_LIB_DIR
315+
docker cp -L $(docker create --rm quay.io/pypa/manylinux2014_aarch64:latest):/opt/python/cp38-cp38 /opt/python
316+
cd examples/namespace_package
317+
python -m pip install wheel
318+
python setup.py bdist_wheel --plat-name manylinux2014_aarch64
319+
ls -la dist/
320+
- uses: uraimo/[email protected]
272321
name: Install built wheel
273322
with:
274323
arch: aarch64

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ Finished processing dependencies for hello_rust==1.0
7979

8080
Or you can use commands like `bdist_wheel` (after installing `wheel`). See also [the notes in the documentation about building wheels](https://setuptools-rust.readthedocs.io/en/latest/building_wheels.html).
8181

82-
Cross-compiling is also supported, using either [`crossenv`](https://github.com/benfogle/crossenv) or [`cross`](https://github.com/rust-embedded/cross). For examples see the `test-cross-compile` and `test-cross` Github actions jobs in [`ci.yml`](https://github.com/PyO3/setuptools-rust/blob/main/.github/workflows/ci.yml).
82+
Cross-compiling is also supported, using one of [`crossenv`](https://github.com/benfogle/crossenv), [`cross`](https://github.com/rust-embedded/cross) or [`cargo-zigbuild`](https://github.com/messense/cargo-zigbuild).
83+
For examples see the `test-cross-compile` and `test-cross` and `test-zigbuild` Github actions jobs in [`ci.yml`](https://github.com/PyO3/setuptools-rust/blob/main/.github/workflows/ci.yml).
8384

8485
By default, `develop` will create a debug build, while `install` will create a release build.
8586

examples/namespace_package/Dockerfile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
FROM quay.io/pypa/manylinux2014_aarch64 AS manylinux
22

3-
FROM rustembedded/cross:aarch64-unknown-linux-gnu
4-
5-
RUN apt-get update && \
6-
apt-get install -y software-properties-common && \
7-
add-apt-repository ppa:deadsnakes/ppa && \
8-
apt-get update && \
9-
apt-get install -y python3.8 && \
10-
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
3+
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge
4+
5+
RUN curl -L https://github.com/indygreg/python-build-standalone/releases/download/20220318/cpython-3.8.13+20220318-x86_64-unknown-linux-gnu-install_only.tar.gz | tar -xz -C /usr/local
6+
7+
ENV PATH=/usr/local/python/bin:$PATH
118

129
COPY --from=manylinux /opt/_internal /opt/_internal
1310
COPY --from=manylinux /opt/python /opt/python

0 commit comments

Comments
 (0)