pyo3_build_config::get()
broken inside our proc macro crates when cross-compiling
#4579
Labels
pyo3_build_config::get()
broken inside our proc macro crates when cross-compiling
#4579
Related:
The current implementation of
pyo3_build_config::get()
relies on (in order):DEP_PYTHON_PYO3_CONFIG
environment variable (only set by cargo forbuild.rs
files of crates which are direct dependents ofpyo3-ffi
)TARGET
and reading a cross-compile config from a corresponding subpath ofpyo3-build-config
'sOUT_DIR
PYO3_CONFIG_FILE
, if set (inlined intopyo3-build-config
as part of itsbuild.rs
)pyo3-build-config
as part of itsbuild.rs
)In step 2, the cross-compile config is generated by
pyo3-ffi
is written topyo3-build-config
'sOUT_DIR
. Usingpyo3-build-config
'sOUT_DIR
was chosen because we wanted to share this resolved information across all downstream uses, and onlypyo3-build-config
is the common dependency forpyo3_build_config::get()
. However, this has problems:OUT_DIR
is a temporary sandbox; it's not really well specified that we should ever be abusingOUT_DIR
in this way (root of the bazel issue above)Really, all we need is a mechanism to generate a cross-compile configuration and re-use it across builds. At the moment we can't do this at the same time we inline options 3 and 4 because
pyo3-build-config
'sbuild.rs
doesn't know the final compilation target (pyo3-build-config
is always built for the host target as a build dependency).Unless we can think of a better mechanism to pass data from
pyo3-ffi
'sbuild.rs
to downstream uses in the proc macros and other crates, the only option I can think of is to add extraPYO3_CROSS_
environment variables (maybePYO3_CROSS_TARGET
) which can be used bypyo3-build-config
to inline a complete config.maturin
andsetuptools-rust
might at least be able to set these automatically.Possibly there's an upstream feature request for
cargo
here which could solve the problem more cleanly in the future. But we need a solution for existing MSRV as well :(Minor aside, Step 1 is also probably a redundant optimization because it's likely rarely hit and when present should resolve to whichever of 2, 3, or 4 was selected by
pyo3-ffi
's build.The text was updated successfully, but these errors were encountered: