diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b20a26a433b..46c04767081 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,6 +211,10 @@ jobs: - name: Build (all additive features) run: cargo build --lib --tests --no-default-features --features "${{ steps.settings.outputs.all_additive_features }}" + - if: ${{ startsWith(matrix.python-version, 'pypy') }} + name: Build PyPy (abi3-py36) + run: cargo build --lib --tests --no-default-features --features "abi3-py36 ${{ steps.settings.outputs.all_additive_features }}" + # Run tests (except on PyPy, because no embedding API). - if: ${{ !startsWith(matrix.python-version, 'pypy') }} name: Test diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cf8397f480..2ee61febb42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix creating `#[classattr]` by functions with the name of a known magic method. [#1969](https://github.com/PyO3/pyo3/pull/1969) +- Fix build failure on PyPy when abi3 features are activated. [#1991](https://github.com/PyO3/pyo3/pull/1991) - Fix mingw platform detection. [#1993](https://github.com/PyO3/pyo3/pull/1993) ## [0.15.0] - 2021-11-03 diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs index aaf2f3c9753..6a73b3b97d6 100644 --- a/pyo3-build-config/src/impl_.rs +++ b/pyo3-build-config/src/impl_.rs @@ -135,10 +135,6 @@ impl InterpreterConfig { println!("cargo:rustc-cfg=Py_3_{}", i); } - if self.abi3 { - println!("cargo:rustc-cfg=Py_LIMITED_API"); - } - if self.implementation.is_pypy() { println!("cargo:rustc-cfg=PyPy"); if self.abi3 { @@ -147,7 +143,9 @@ impl InterpreterConfig { See https://foss.heptapod.net/pypy/pypy/-/issues/3397 for more information." ); } - }; + } else if self.abi3 { + println!("cargo:rustc-cfg=Py_LIMITED_API"); + } for flag in &self.build_flags.0 { println!("cargo:rustc-cfg=py_sys_config=\"{}\"", flag) @@ -221,7 +219,12 @@ print("mingw", get_platform().startswith("mingw")) let implementation = map["implementation"].parse()?; let lib_name = if cfg!(windows) { - default_lib_name_windows(version, abi3, map["mingw"].as_str() == "True") + default_lib_name_windows( + version, + implementation, + abi3, + map["mingw"].as_str() == "True", + ) } else { default_lib_name_unix( version, @@ -989,7 +992,12 @@ fn windows_hardcoded_cross_compile( version, shared: true, abi3, - lib_name: Some(default_lib_name_windows(version, abi3, false)), + lib_name: Some(default_lib_name_windows( + version, + PythonImplementation::CPython, + abi3, + false, + )), lib_dir: cross_compile_config.lib_dir.to_str().map(String::from), executable: None, pointer_width: None, @@ -1028,8 +1036,13 @@ fn load_cross_compile_config( // This contains only the limited ABI symbols. const WINDOWS_ABI3_LIB_NAME: &str = "python3"; -fn default_lib_name_windows(version: PythonVersion, abi3: bool, mingw: bool) -> String { - if abi3 { +fn default_lib_name_windows( + version: PythonVersion, + implementation: PythonImplementation, + abi3: bool, + mingw: bool, +) -> String { + if abi3 && !implementation.is_pypy() { WINDOWS_ABI3_LIB_NAME.to_owned() } else if mingw { // https://packages.msys2.org/base/mingw-w64-python @@ -1389,22 +1402,52 @@ mod tests { #[test] fn default_lib_name_windows() { + use PythonImplementation::*; assert_eq!( - super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, false, false), + super::default_lib_name_windows( + PythonVersion { major: 3, minor: 6 }, + CPython, + false, + false + ), "python36", ); assert_eq!( - super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, true, false), + super::default_lib_name_windows( + PythonVersion { major: 3, minor: 6 }, + CPython, + true, + false + ), "python3", ); assert_eq!( - super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, false, true), + super::default_lib_name_windows( + PythonVersion { major: 3, minor: 6 }, + CPython, + false, + true + ), "python3.6", ); assert_eq!( - super::default_lib_name_windows(PythonVersion { major: 3, minor: 6 }, true, true), + super::default_lib_name_windows( + PythonVersion { major: 3, minor: 6 }, + CPython, + true, + true + ), "python3", ); + assert_eq!( + super::default_lib_name_windows( + PythonVersion { major: 3, minor: 6 }, + PyPy, + true, + false + ), + "python36", + ); } #[test]