Commit Graph

9 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 70030f130d python: drop support for 3.6 2021-11-20 13:02:42 +00:00
Gregory Szorc 1e951d5d8b pyo3-build-config: add a crate feature to control build script
I have a use case in PyOxidizer where I want to use the
pyo3-build-config crate as a library crate so I can access the
`InterpreterConfig` struct so I can read/write config files without
reinventing the wheel.

This is doable before this commit. But it requires that the
build environment have a Python interpreter. This is undesirable
for library usage.

This commit introduces a cargo feature flag to control whether the
build script does anything. The feature flag must be present for
the build script to resolve a config. The feature flag is enabled
by default for backwards compatibility. The pyo3 and pyo3-macros-backend
crates use this feature by default, for backwards compatibility and
because it is the reasonable default.

This is probably room to conditionalize some APIs and other behavior
based on this feature flag. But we stop short of doing that for
the time being.
2021-09-01 19:44:54 -07:00
Gregory Szorc c9c606f7c6 build: enable suppression of `cargo:rustc-link-*` lines
PyOxidizer requires advanced control over the settings used to link
libpython. We recently implemented support for configuration files
defining explicit lines to emit from build scripts to give callers
control over what lines to emit from build scripts so use cases
like PyOxidizer's are feasible without hacks in PyO3's code base.

However, the default logic in `emit_link_config()` may not be
appropriate in scenarios where link settings are provided via this
"extra lines" mechanism. The default logic may prohibit use of or
interfere with desired settings provided externally.

This commit defines a new field on the interpreter config that
suppresses the emission of the default link control logic from the
`pyo3` build script. It effectively gives advanced consumers like
PyOxidizer full control over link logic while minimally polluting
PyO3's build logic.

I thought about implementing this control as a crate feature. But
given the expected target audience size of ~1, I thought a crate
feature was too visible for a power user feature and decided to
implement it via the configuration file.
2021-08-30 10:01:36 -07:00
Gregory Szorc 04c77e35c5 build: support emitting arbitrary lines from pyo3 build script
PyOxidizer needs to do some... questionable things with regards to
configuring how the Python interpreter is linked. The way I solved this
problem for the `cpython` / `python3-sys` crates was by adding a bunch
of crate features to control what `cargo:` lines were emitted by the
build scripts. This added a lot of complexity to the those crates for
a target audience of ~1.

Now that PyO3 has support for config files to control settings, this
provides a richer mechanism than crate features to influence the build
script.

This commit defines a new field on the `InterpreterConfig` struct to
hold an arbitrary list of strings/lines that should be emitted by
the build script. This field is only every populated when parsing config
files and it is only read by pyo3's build script to `println!()`
additional values.

My intended use case for this is to have PyOxidizer effectively control
the interpreter link settings via the config file (at my own peril)
while having minimal impact on the maintainability of PyO3's code base.
Given the complexity of the link hacks employed, you probably don't want
this polluting pyo3's code base.
2021-08-30 09:52:11 -07:00
David Hewitt 49387e9a70 pyo3-build-config: many tidy ups 2021-08-05 23:19:43 +01:00
David Hewitt 9507979d93
pyo3-build-config: inline config when not cross compiling 2021-08-04 12:54:45 +01:00
David Hewitt 8fb4ce6fbc pyo3-build-config: fix cross compilation 2021-06-26 14:19:03 +01:00
David Hewitt 79c7149d52 pyo3-build-config: new crate to re-use build.rs across crates 2021-05-20 09:03:33 +01:00