Skip to content

Commit d85e8d6

Browse files
authored
Merge pull request #185 from davidhewitt/cross-try-2
Add support for cross, try 2
2 parents c36eeb0 + 917c5e5 commit d85e8d6

File tree

8 files changed

+381
-206
lines changed

8 files changed

+381
-206
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
PYTHON: ${{ matrix.python-version }}
9696
run: |
9797
for example_dir in examples/*; do
98-
tox -c $example_dir -e py
98+
tox -c $example_dir -e py -vvvv
9999
done
100100
101101
- name: Test macOS universal2
@@ -224,3 +224,48 @@ jobs:
224224
pip3 install rust_with_cffi/dist/rust_with_cffi*.whl
225225
python3 -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
226226
python3 -c "from rust_with_cffi.cffi import lib; assert lib.cffi_func() == 15"
227+
228+
test-cross:
229+
runs-on: ubuntu-latest
230+
steps:
231+
- uses: actions/checkout@master
232+
- name: Setup python
233+
uses: actions/setup-python@v2
234+
with:
235+
python-version: 3.8
236+
- uses: actions-rs/toolchain@v1
237+
with:
238+
profile: minimal
239+
toolchain: stable
240+
override: true
241+
- name: Install cross
242+
run: cargo install cross
243+
- name: Build package
244+
run: pip install -e .
245+
- name: Build wheel using cross
246+
shell: bash
247+
env:
248+
CARGO: cross
249+
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
250+
PYO3_CROSS_LIB_DIR: /opt/python/cp38-cp38/lib
251+
run: |
252+
cd examples/namespace_package
253+
docker build -t cross-pyo3:aarch64-unknown-linux-gnu .
254+
python -m pip install wheel
255+
python setup.py bdist_wheel --plat-name manylinux2014_aarch64
256+
ls -la dist/
257+
- uses: uraimo/[email protected]
258+
name: Install built wheel
259+
with:
260+
arch: aarch64
261+
distro: ubuntu20.04
262+
dockerRunArgs: |
263+
--volume "${PWD}/examples/namespace_package:/io"
264+
install: |
265+
apt-get update
266+
apt-get install -y --no-install-recommends python3 python3-pip
267+
pip3 install -U pip
268+
run: |
269+
pip3 install namespace_package --no-index --find-links /io/dist/ --force-reinstall
270+
python3 -c "from namespace_package import rust; assert rust.rust_func() == 14"
271+
python3 -c "from namespace_package import python; assert python.python_func() == 15"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Added
6+
- Add support for cross-compiling using [`cross`](https://github.com/rust-embedded/cross). [#185](https://github.com/PyO3/setuptools-rust/pull/185)
7+
58
### Fixed
69
- Fix incompatibility with Python 3.6.0 using default values for NamedTuple classes. [#184](https://github.com/PyO3/setuptools-rust/pull/184)
710

examples/namespace_package/Cross.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
image = "cross-pyo3:aarch64-unknown-linux-gnu"
3+
4+
[build.env]
5+
passthrough = [
6+
"RUST_BACKTRACE",
7+
"RUST_LOG",
8+
"PYO3_CROSS_LIB_DIR",
9+
]

examples/namespace_package/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM quay.io/pypa/manylinux2014_aarch64 AS manylinux
2+
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
11+
12+
COPY --from=manylinux /opt/_internal /opt/_internal
13+
COPY --from=manylinux /opt/python /opt/python

0 commit comments

Comments
 (0)