Commit Graph

85 Commits

Author SHA1 Message Date
Sergey Kvachonok 29476b0d0d pyo3-build-config: Inline the `PYO3_NO_PYTHON` switch
This patch folds the `PYO3_NO_PYTHON` + `abi3` special case into
the existing native and cross compilation code paths.

The cross compilation route is now guaranteed to behave the same
whether `PYO3_NO_PYTHON` is set or not (except for sysconfigdata
discovery for the Unix targets).

The native compilation route now stores the hardcoded abi3 interpreter
configuration in place of the discovered configuration blob.
2022-04-05 17:19:49 +03:00
David Hewitt 1ae0971a09 release: 0.16.3 2022-04-05 04:05:57 +01:00
Sergey Kvachonok 80675361f4 pyo3-build-config: Add `PYO3_CROSS_PYTHON_IMPLEMENTATION` env var
Adds a new cross-compile target interpreter configuration
environment variable.

This feature allows PyO3 to target PyPy on both Windows and Unix
cross compile targets.
2022-04-04 15:23:11 +03:00
Sergey Kvachonok ccda497e04 pyo3-build-config: Create per-target cross config files
Rename `$OUT_DIR/pyo3-cross-compile-config.txt` to
`$OUT_DIR/<triple>/pyo3-build-config.txt` to exclude the possibility
of using stale build configuration data when the build target changes.

Use the presence of the corresponding build configuration file
in the `pyo3-build-config` build script output directory
to detect whether we are cross compiling or not.

This patch enables cross compilation without using
any of `PYO3_CROSS_*` env variables in many cases.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok 328e7d69f6 pyo3-build-config: Try "default" cross-compilation
Try to generalize `windows_hardcoded_cross_compile()`
to all supported target platforms (when possible).
Rename it to `default_cross_compile()` and add some unit tests.

Rewrite `load_cross_compile_config()` to fall back to
the default interpreter configuration when no other config
information sources are available.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok 54ae025722 pyo3-build-config: Make `lib_dir` optional in `CrossCompileConfig`
Change the `CrossCompileConfig` structure definition and make
the public `lib_dir` field optional to support more flexible
cross-compilation configuration in the future.

FIXME: This change breaks the public `pyo3-build-config` crate API.

Update the sysconfigdata extraction functions to fall through
when `lib_dir` field is not set.

WIP: Add `unwrap()` stubs to the main cross compile switch.
2022-04-01 11:32:46 +03:00
Sergey Kvachonok 9b45a19161 pyo3-build-config: Replace `TargetInfo` with `target_lexicon::Triple`
Add a new public crate function `cross_compile_from_to()` using
`target_lexicon::Triple` arguments instead of plain strings
used in `cross_compile()`.

Deprecate `pyo3_build_config::cross_compile()` since v0.17.

Attempt to extract common code patterns into methods and standalone
helper functions. Add docstrings to the new private items.
Make some of the new helper functions public within the PyO3 crate
and reuse them in the build scripts.

Add PYO3_CROSS_PYTHON_VERSION parsing unit test.

Add a ChangeLog entry mentioning the new `pyo3-build-config` API.
2022-04-01 09:36:49 +03:00
David Hewitt 16ee22c7cc
Merge pull request #2244 from mejrs/lint-more
Add more lints
2022-03-23 13:40:35 +00:00
mejrs 00ea040834 Feedback 2022-03-23 13:30:32 +01:00
David Hewitt 2813c87eaf
Merge pull request #2092 from aganders3/export-conf
Add export-config feature to pyo3-build-config
2022-03-23 11:16:04 +00:00
Sergey Kvachonok 5237000317 pyo3-build-config: Fix `abi3-py310` feature
Fix `abi3-py310` feature: use Python 3.10 ABI when available
instead of silently falling back to the 3.9 ABI.
2022-03-23 09:45:25 +03:00
Ashley Anderson 4a62a62cae Improvements based on code review: API and documentation. 2022-03-21 12:55:39 -04:00
Ashley Anderson bbe7a493d6 Refactor to serialize the whole InterpreterConfig into DEP_PYTHON_PYO3_CONFIG 2022-03-17 12:10:38 -04:00
Ashley Anderson bc356f23e0 Fix coverage for pyo3-build-config CI ("full" feature) 2022-03-17 11:20:37 -04:00
Ashley Anderson 161d79fae3 Fix test for MSRV 2022-03-17 11:20:37 -04:00
Ashley Anderson 14bd6282ad Add test for export-config round trip. 2022-03-17 11:20:37 -04:00
Ashley Anderson 04b8652612 Fix test on windows (line ending mismatch). 2022-03-17 11:20:37 -04:00
Ashley Anderson ef4b91256d Add tests for run_python_script*. 2022-03-17 11:20:36 -04:00
Ashley Anderson cb3effdb96 Additon conditional compilation for InterpreterConfig::from_pyo3_export_config 2022-03-17 11:19:27 -04:00
Ashley Anderson 755bf97fdb Add export-config feature to pyo3-build-config. 2022-03-17 11:19:27 -04:00
Kevin Phillips 34ff72f6ba Added a test for PYTHONFRAMEWORK 2022-03-17 08:41:26 +01:00
Kevin Phillips 13f13e5ee1 pyo3-build-config: Change for from_sysconfigdata to set the shared property based on PYTHONFRAMEWORK in addition to Py_ENABLE_SHARED in order that a macos Framework build is considered shared just like the logic in from_interpreter 2022-03-17 07:42:29 +01:00
David Hewitt 52d2c78ae1 pyo3-build-config: fix windows "cross-compile" panic 2022-03-16 13:22:00 +01:00
Adam Reichold 922bbfc92d release: 0.16.2 2022-03-15 19:20:00 +01:00
David Hewitt 7056bae21f release: 0.16.1 2022-03-05 16:21:44 +00:00
messense afe5221724
Fix cross compiling to aarch64 macOS 2022-03-04 17:22:50 +08:00
David Hewitt 6fda258f01
Merge pull request #2198 from PanQL/fix-interpreter-script
use platform.system to check if it is on windows
2022-03-03 09:05:02 +00:00
David Hewitt 5f39e483c5
Merge pull request #2196 from davidhewitt/more-clippy
clippy: enable some more lints
2022-03-03 08:58:41 +00:00
David Hewitt ddf13ea98f clippy: enable some more lints 2022-03-03 07:23:28 +00:00
Adam Reichold 12be3f219d Enable the resolve-config feature of pyo3-build-config on docs.rs to make the dependent functionality visible. 2022-03-01 10:31:38 +01:00
PanQL 5ac495e547 use platform.system to check if it is on windows 2022-03-01 17:26:19 +08:00
David Hewitt 4c434a21bd release: 0.16.0 2022-02-27 20:28:51 +00:00
David Hewitt efbf92bd52 pypy: don't allow abi to be adjusted by abi3 flag 2022-02-25 07:28:54 +00:00
David Hewitt f3df59c76b pypy: include minor version in library on Python 3.9 2022-02-25 07:28:22 +00:00
mejrs f346d1c86f Move emitting cfgs to pyo3-build-config 2022-02-18 19:20:32 +01:00
Ashley Anderson c30ca03b60
Expose cross compiling configuration from pyo3-build-config (#1996)
* Initial refactor - expose cross-compiling functions and add necessary fields to InterpreterConfig

* Refactor cross_compiling to take arch/vendor/os separately.

* Address review comments.

* Update changelog with note about pyo3-build-config APIs.

* Fix panic when parsing ABI tag on Windows.

* Update parse_sysconfigdata test to best-guess values for linux.

* Revert added fields in InterpreterConfig.

* Refactor parse_sysconfigdata to return Sysconfigdata (HashMap). Add InterpreterConfig::from_sysconfigdata.

* Update BuildFlags test to use from_sysconfigdata.

* Add tests for from_sysconfigdata. Refactor Sysconfigdata API to be more open.

* Add basic tests for not cross compiling. Add some error handling.

* Address review comments.

* Update search_lib_dir to recurse into lib and pypy dirs.

* Look even harder for sysconfigdata.

* Add skip-build-config feature.

* Revert skip-build-config feature.

* Suppress cargo:rerun-if-env-changed without resolve-config feature.
2021-12-16 00:18:37 +00:00
David Hewitt a5ef9ff64a ci: clippy whole workspace 2021-12-09 08:11:28 +00:00
Georg Brandl 9990bf9d31 Fix some clippy and dead code warnings. 2021-11-24 09:11:39 +01:00
David Hewitt 70030f130d python: drop support for 3.6 2021-11-20 13:02:42 +00:00
David Hewitt b9cc10f3fb pyo3-build-config: don't enable resolve-config by default 2021-11-19 14:19:24 +00:00
David Hewitt eb5059acc7 release: 0.15.1 2021-11-18 07:34:22 +00:00
messense f01595163c Don't link to python3.lib for PyPy on Windows 2021-11-15 15:40:29 +08:00
messense 73c3911748 Don't emit `Py_LIMITED_API` cfg for PyPy 2021-11-15 15:40:27 +08:00
messense 2325c283b0 Fix mingw platform detection 2021-11-15 15:15:16 +08:00
David Hewitt 47747444c7 release: 0.15.0 2021-11-03 23:00:38 +00:00
Giovanni Barillari c06058888f review sysconfigdata filename match rules to support cp37m 2021-10-12 23:41:26 +01:00
David Hewitt a5d0aa777c py310: add abi3-py310 feature 2021-09-26 16:21:35 +01:00
Sergey Kvachonok 2f74ab0d23 build-config: Always pass `abi3` flag to `default_lib_name_windows()`
Hardcoding `false` here leads to an incorrect abi3 DLL name
when cross-compiling to Windows.
2021-09-22 07:30:21 +01:00
David Hewitt 097d7e09cb pyo3-build-config: fix location for conda interpreter on windows 2021-09-16 23:38:46 +01:00
David Hewitt dca02a92ce changelog: updates for 0.14.5 backports 2021-09-05 15:19:36 +01:00