@@ -39,6 +39,94 @@ def test_sdist_vendor(session: nox.Session):
3939 session .run ("cargo" , "build" , "--offline" , external = True )
4040
4141
42+ @nox .session (name = "test-crossenv" , venv_backend = None )
43+ def test_crossenv (session : nox .Session ):
44+ try :
45+ arch = session .posargs [0 ]
46+ except IndexError :
47+ arch = "aarch64"
48+ print (arch )
49+
50+ if arch == "aarch64" :
51+ rust_target = "aarch64-unknown-linux-gnu"
52+ docker_platform = "aarch64"
53+ elif arch == "armv7" :
54+ rust_target = "armv7-unknown-linux-gnueabihf"
55+ docker_platform = "linux/arm/v7"
56+ else :
57+ raise RuntimeError ("don't know rust target for arch: " + arch )
58+
59+ script_build = f"""set -ex
60+ curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
61+ source ~/.cargo/env
62+ rustup target add { rust_target }
63+
64+ # https://github.com/pypa/setuptools_scm/issues/707
65+ git config --global --add safe.directory /io
66+
67+ cd examples/rust_with_cffi/
68+ python3.9 -m pip install crossenv
69+ 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
70+ . venv/bin/activate
71+
72+ build-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1
73+ cross-pip install -U pip>=23.2.1 setuptools>=68.0.0 wheel>=0.41.1
74+ build-pip install cffi
75+ cross-expose cffi
76+ cross-pip install -e ../../
77+ cross-pip list
78+
79+ export DIST_EXTRA_CONFIG=/tmp/build-opts.cfg
80+ echo -e "[bdist_wheel]\n py_limited_api=cp37" > $DIST_EXTRA_CONFIG
81+
82+ rm -rf dist/*
83+ cross-pip wheel --no-build-isolation --no-deps --wheel-dir dist . -vv
84+ ls -la dist/
85+ python -m zipfile -l dist/*.whl # debug all files inside wheel file
86+ """
87+
88+ pwd = os .getcwd ()
89+ session .run (
90+ "docker" ,
91+ "run" ,
92+ "--rm" ,
93+ "-v" ,
94+ f"{ pwd } :/io" ,
95+ "-w" ,
96+ "/io" ,
97+ f"messense/manylinux2014-cross:{ arch } " ,
98+ "bash" ,
99+ "-c" ,
100+ script_build ,
101+ external = True ,
102+ )
103+
104+ script_check = """set -ex
105+ cd /io/examples
106+ python3 --version
107+ pip3 install rust_with_cffi/dist/rust_with_cffi*.whl
108+ python3 -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
109+ python3 -c "from rust_with_cffi.cffi import lib; assert lib.cffi_func() == 15"
110+ """
111+
112+ session .run (
113+ "docker" ,
114+ "run" ,
115+ "--rm" ,
116+ "-v" ,
117+ f"{ pwd } :/io" ,
118+ "-w" ,
119+ "/io" ,
120+ "--platform" ,
121+ docker_platform ,
122+ "python:3.9" ,
123+ "bash" ,
124+ "-c" ,
125+ script_check ,
126+ external = True ,
127+ )
128+
129+
42130@nox .session ()
43131def mypy (session : nox .Session ):
44132 session .install ("mypy" , "fat_macho" , "types-setuptools" , "." )
0 commit comments