Skip to content

Commit

Permalink
Merge pull request #963 from messense/pypy-abi3-cross-compile
Browse files Browse the repository at this point in the history
Add support for cross compiling PyPy wheels when abi3 feature is enabled
  • Loading branch information
messense authored Jun 10, 2022
2 parents 7dcd12d + f19034a commit 1e3510f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,9 @@ jobs:
# Use PYO3_CROSS_LIB_DIR
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 --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml
unset PYO3_CROSS_LIB_DIR
# Test abi3
cargo run --target x86_64-unknown-linux-gnu -- build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-pure/Cargo.toml
' > build-wheel.sh
docker run --rm -v "$PWD":/io -w /io messense/manylinux2014-cross:${{ matrix.platform.arch }} bash build-wheel.sh
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add support for using bundled python sysconfigs for PyPy when abi3 feature is enabled in [#958](https://github.com/PyO3/maturin/pull/958)
* Set `PYO3_PYTHON` env var for PyPy when abi3 is enabled in [#960](https://github.com/PyO3/maturin/pull/960)
* Add sysconfigs for x64 Windows PyPy in [#962](https://github.com/PyO3/maturin/pull/962)
* Add support for cross compiling PyPy wheels when abi3 feature is enabled in [#963](https://github.com/PyO3/maturin/pull/963)

## [0.12.19] - 2022-06-05

Expand Down
19 changes: 19 additions & 0 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,25 @@ pub fn find_interpreter(
platform: None,
runnable: false,
}])
} else if target.cross_compiling() {
let mut interps = Vec::with_capacity(interpreters.len());
let mut pypys = Vec::new();
for interp in interpreters {
if matches!(interp.interpreter_kind, InterpreterKind::PyPy) {
pypys.push(PathBuf::from(format!(
"pypy{}.{}",
interp.major, interp.minor
)));
} else {
interps.push(interp);
}
}
// cross compiling to PyPy with abi3 feature enabled,
// we cannot use host pypy so switch to bundled sysconfig instead
if !pypys.is_empty() {
interps.extend(find_interpreter_in_sysconfig(&pypys, target)?)
}
Ok(interps)
} else {
Ok(interpreters)
}
Expand Down

0 comments on commit 1e3510f

Please sign in to comment.