Skip to content

Commit

Permalink
Merge pull request #185 from davidhewitt/cross-try-2
Browse files Browse the repository at this point in the history
Add support for cross, try 2
  • Loading branch information
davidhewitt authored Nov 28, 2021
2 parents c36eeb0 + 917c5e5 commit d85e8d6
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 206 deletions.
47 changes: 46 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
PYTHON: ${{ matrix.python-version }}
run: |
for example_dir in examples/*; do
tox -c $example_dir -e py
tox -c $example_dir -e py -vvvv
done
- name: Test macOS universal2
Expand Down Expand Up @@ -224,3 +224,48 @@ jobs:
pip3 install rust_with_cffi/dist/rust_with_cffi*.whl
python3 -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
python3 -c "from rust_with_cffi.cffi import lib; assert lib.cffi_func() == 15"
test-cross:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install cross
run: cargo install cross
- name: Build package
run: pip install -e .
- name: Build wheel using cross
shell: bash
env:
CARGO: cross
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
PYO3_CROSS_LIB_DIR: /opt/python/cp38-cp38/lib
run: |
cd examples/namespace_package
docker build -t cross-pyo3:aarch64-unknown-linux-gnu .
python -m pip install wheel
python setup.py bdist_wheel --plat-name manylinux2014_aarch64
ls -la dist/
- uses: uraimo/[email protected]
name: Install built wheel
with:
arch: aarch64
distro: ubuntu20.04
dockerRunArgs: |
--volume "${PWD}/examples/namespace_package:/io"
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip
run: |
pip3 install namespace_package --no-index --find-links /io/dist/ --force-reinstall
python3 -c "from namespace_package import rust; assert rust.rust_func() == 14"
python3 -c "from namespace_package import python; assert python.python_func() == 15"
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Added
- Add support for cross-compiling using [`cross`](https://github.com/rust-embedded/cross). [#185](https://github.com/PyO3/setuptools-rust/pull/185)

### Fixed
- Fix incompatibility with Python 3.6.0 using default values for NamedTuple classes. [#184](https://github.com/PyO3/setuptools-rust/pull/184)

Expand Down
9 changes: 9 additions & 0 deletions examples/namespace_package/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[target.aarch64-unknown-linux-gnu]
image = "cross-pyo3:aarch64-unknown-linux-gnu"

[build.env]
passthrough = [
"RUST_BACKTRACE",
"RUST_LOG",
"PYO3_CROSS_LIB_DIR",
]
13 changes: 13 additions & 0 deletions examples/namespace_package/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM quay.io/pypa/manylinux2014_aarch64 AS manylinux

FROM rustembedded/cross:aarch64-unknown-linux-gnu

RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.8 && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

COPY --from=manylinux /opt/_internal /opt/_internal
COPY --from=manylinux /opt/python /opt/python
Loading

0 comments on commit d85e8d6

Please sign in to comment.