diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2435280..8b4604cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -202,58 +202,14 @@ jobs: fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }} matrix: platform: [ - { target: "aarch64-unknown-linux-gnu", arch: "aarch64" }, - { target: "armv7-unknown-linux-gnueabihf", arch: "armv7" }, + { arch: "aarch64" }, + { arch: "armv7" }, ] steps: - uses: actions/checkout@v3 - - name: Build wheels - run: | - echo 'set -ex - curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable - source ~/.cargo/env - rustup target add ${{ matrix.platform.target }} - - # https://github.com/pypa/setuptools_scm/issues/707 - git config --global --add safe.directory /io - - cd examples/rust_with_cffi/ - python3.9 -m pip install crossenv - python3.9 -m crossenv "/opt/python/cp39-cp39/bin/python3" --cc $TARGET_CC --cxx $TARGET_CXX --sysroot $TARGET_SYSROOT --env LIBRARY_PATH= --manylinux manylinux1 venv - . venv/bin/activate - - build-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1 - cross-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1 - build-pip install cffi - cross-expose cffi - cross-pip install -e ../../ - cross-pip list - - export DIST_EXTRA_CONFIG=/tmp/build-opts.cfg - echo -e "[bdist_wheel]\npy_limited_api=cp37" > $DIST_EXTRA_CONFIG - - cross-pip wheel --no-build-isolation --no-deps --wheel-dir dist . -vv - ls -la dist/ - python -m zipfile -l dist/*.whl # debug all files inside wheel file - ' > build-wheels.sh - - docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheels.sh - - name: Install abi3 wheel and run tests - uses: uraimo/run-on-arch-action@v2.5.0 - with: - arch: ${{ matrix.platform.arch }} - distro: ubuntu20.04 - dockerRunArgs: | - --volume "${PWD}/examples:/examples" - install: | - apt-get update - apt-get install -y --no-install-recommends python3 python3-dev python3-pip build-essential libffi-dev - run: | - cd /examples - python3 --version - 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" + - uses: docker/setup-qemu-action@v2 + - run: pip install nox + - run: nox -s test-crossenv -- ${{ matrix.platform.arch }} test-cross: runs-on: ubuntu-latest diff --git a/noxfile.py b/noxfile.py index d0030882..c00b82e9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -39,6 +39,94 @@ def test_sdist_vendor(session: nox.Session): session.run("cargo", "build", "--offline", external=True) +@nox.session(name="test-crossenv", venv_backend=None) +def test_crossenv(session: nox.Session): + try: + arch = session.posargs[0] + except IndexError: + arch = "aarch64" + print(arch) + + if arch == "aarch64": + rust_target = "aarch64-unknown-linux-gnu" + docker_platform = "aarch64" + elif arch == "armv7": + rust_target = "armv7-unknown-linux-gnueabihf" + docker_platform = "linux/arm/v7" + else: + raise RuntimeError("don't know rust target for arch: " + arch) + + script_build = f"""set -ex +curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable +source ~/.cargo/env +rustup target add {rust_target} + +# https://github.com/pypa/setuptools_scm/issues/707 +git config --global --add safe.directory /io + +cd examples/rust_with_cffi/ +python3.9 -m pip install crossenv +python3.9 -m crossenv "/opt/python/cp39-cp39/bin/python3" --cc $TARGET_CC --cxx $TARGET_CXX --sysroot $TARGET_SYSROOT --env LIBRARY_PATH= --manylinux manylinux1 venv +. venv/bin/activate + +build-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1 +cross-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1 +build-pip install cffi +cross-expose cffi +cross-pip install -e ../../ +cross-pip list + +export DIST_EXTRA_CONFIG=/tmp/build-opts.cfg +echo -e "[bdist_wheel]\npy_limited_api=cp37" > $DIST_EXTRA_CONFIG + +rm -rf dist/* +cross-pip wheel --no-build-isolation --no-deps --wheel-dir dist . -vv +ls -la dist/ +python -m zipfile -l dist/*.whl # debug all files inside wheel file + """ + + pwd = os.getcwd() + session.run( + "docker", + "run", + "--rm", + "-v", + f"{pwd}:/io", + "-w", + "/io", + f"messense/manylinux2014-cross:{arch}", + "bash", + "-c", + script_build, + external=True, + ) + + script_check = """set -ex +cd /io/examples +python3 --version +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" +""" + + session.run( + "docker", + "run", + "--rm", + "-v", + f"{pwd}:/io", + "-w", + "/io", + "--platform", + docker_platform, + "python:3.9", + "bash", + "-c", + script_check, + external=True, + ) + + @nox.session() def mypy(session: nox.Session): session.install("mypy", "fat_macho", "types-setuptools", ".")