Skip to content

Commit 84592ef

Browse files
messensedavidhewitt
authored andcommitted
Add cross compilation test with crossenv
1 parent ad05f1c commit 84592ef

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,49 @@ jobs:
169169
pip install rust_with_cffi/dist/rust_with_cffi*.whl
170170
python -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
171171
python -c "from rust_with_cffi.cffi import lib; assert lib.cffi_func() == 15"
172+
173+
test-cross-compile:
174+
runs-on: ubuntu-latest
175+
strategy:
176+
matrix:
177+
platform: [
178+
{ target: "aarch64-unknown-linux-gnu", arch: "aarch64" },
179+
{ target: "armv7-unknown-linux-gnueabihf", arch: "armv7" },
180+
]
181+
steps:
182+
- uses: actions/checkout@master
183+
- name: Build Wheels
184+
run: |
185+
echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
186+
source ~/.cargo/env
187+
rustup target add ${{ matrix.platform.target }}
188+
cd examples/rust_with_cffi/
189+
python3.6 -m pip install crossenv
190+
python3.6 -m crossenv "/opt/python/cp36-cp36m/bin/python3" --cc $TARGET_CC --cxx $TARGET_CXX --sysroot $TARGET_SYSROOT --env LIBRARY_PATH= --manylinux manylinux1 venv
191+
. venv/bin/activate
192+
build-pip install cffi wheel
193+
cross-expose cffi
194+
pip install wheel
195+
pip install -e ../../
196+
unset CARGO_BUILD_TARGET
197+
python setup.py bdist_wheel --py-limited-api=cp36
198+
ls -la dist/
199+
' > build-wheels.sh
200+
201+
docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheels.sh
202+
- name: Install abi3 wheel and run tests
203+
uses: uraimo/[email protected]
204+
with:
205+
arch: ${{ matrix.platform.arch }}
206+
distro: ubuntu20.04
207+
dockerRunArgs: |
208+
--volume "${PWD}/examples:/examples"
209+
install: |
210+
apt-get update
211+
apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential libffi-dev
212+
run: |
213+
cd /examples
214+
python3 --version
215+
pip3 install rust_with_cffi/dist/rust_with_cffi*.whl
216+
python3 -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
217+
python3 -c "from rust_with_cffi.cffi import lib; assert lib.cffi_func() == 15"

0 commit comments

Comments
 (0)