diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 001eff698..1d8aefe85 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -211,6 +211,7 @@ jobs: strategy: matrix: platform: + # CPython - target: aarch64-unknown-linux-gnu arch: aarch64 abi: cp36-cp36m @@ -220,6 +221,13 @@ jobs: - target: s390x-unknown-linux-gnu arch: s390x abi: cp310-cp310 + # PyPy + - target: aarch64-unknown-linux-gnu + arch: aarch64 + abi: pp37-pypy37_pp73 + - target: aarch64-unknown-linux-gnu + arch: aarch64 + abi: pp38-pypy38_pp73 steps: - uses: actions/checkout@v2 - name: Build Wheels @@ -227,7 +235,7 @@ jobs: echo 'curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal source ~/.cargo/env rustup target add ${{ matrix.platform.target }} - export PYO3_CROSS_LIB_DIR=/opt/python/${{ matrix.platform.abi }}/lib + export PYO3_CROSS_LIB_DIR=/opt/python/${{ matrix.platform.abi }} cargo run --target x86_64-unknown-linux-gnu -- build -i python3.9 --release --out dist --no-sdist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml ' > build-wheel.sh docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh diff --git a/src/build_options.rs b/src/build_options.rs index a06dcbeaa..2c90e1554 100644 --- a/src/build_options.rs +++ b/src/build_options.rs @@ -529,6 +529,11 @@ pub fn find_interpreter( env::set_var("PYTHON_SYS_EXECUTABLE", &host_python.executable); let sysconfig_path = find_sysconfigdata(cross_lib_dir.as_ref(), target)?; + env::set_var( + "MATURIN_PYTHON_SYSCONFIGDATA_DIR", + sysconfig_path.parent().unwrap(), + ); + let sysconfig_data = parse_sysconfigdata(host_python, sysconfig_path)?; let major = sysconfig_data .get("version_major") diff --git a/src/compile.rs b/src/compile.rs index a34876b5e..d4c930461 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -230,6 +230,10 @@ fn compile_target( } } + if let Some(lib_dir) = env::var_os("MATURIN_PYTHON_SYSCONFIGDATA_DIR") { + build_command.env("PYO3_CROSS_LIB_DIR", lib_dir); + } + let mut cargo_build = build_command.spawn().context("Failed to run cargo")?; let mut artifacts = HashMap::new(); diff --git a/src/cross_compile.rs b/src/cross_compile.rs index f59318630..b32c9f8a3 100644 --- a/src/cross_compile.rs +++ b/src/cross_compile.rs @@ -147,12 +147,12 @@ pub fn find_sysconfigdata(lib_dir: &Path, target: &Target) -> Result { /// recursive search for _sysconfigdata, returns all possibilities of sysconfigdata paths fn search_lib_dir(path: impl AsRef, target: &Target) -> Vec { let mut sysconfig_paths = vec![]; - let version_pat = if let Some(v) = + let (cpython_version_pat, pypy_version_pat) = if let Some(v) = env::var_os("PYO3_CROSS_PYTHON_VERSION").map(|s| s.into_string().unwrap()) { - format!("python{}", v) + (format!("python{}", v), format!("pypy{}", v)) } else { - "python3.".into() + ("python3.".into(), "pypy3.".into()) }; for f in fs::read_dir(path.as_ref()).expect("Path does not exist") { let sysc = match &f { @@ -173,7 +173,12 @@ fn search_lib_dir(path: impl AsRef, target: &Target) -> Vec { } search_lib_dir(f.path(), target) } - Ok(f) if starts_with(f, &version_pat) => search_lib_dir(f.path(), target), + Ok(f) if starts_with(f, &cpython_version_pat) => search_lib_dir(f.path(), target), + // PyPy 3.7: /opt/python/pp37-pypy37_pp73/lib_pypy/_sysconfigdata__linux_x86_64-linux-gnu.py + Ok(f) if starts_with(f, "lib_pypy") => search_lib_dir(f.path(), target), + // PyPy 3.8: /opt/python/pp38-pypy38_pp73/lib/pypy3.8/_sysconfigdata__linux_x86_64-linux-gnu.py + Ok(f) if starts_with(f, &pypy_version_pat) => search_lib_dir(f.path(), target), + Ok(f) if starts_with(f, "lib") && f.path().is_dir() => search_lib_dir(f.path(), target), _ => continue, }; sysconfig_paths.extend(sysc);