Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cross compiling PyPy wheels when abi3 feature is enabled #963

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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