Ensure we are cross compiling when any cross env variables are set.

This commit is contained in:
James Hilliard 2021-03-22 07:38:03 -06:00
parent 6e49ba3212
commit 2c3e8b1c50
2 changed files with 36 additions and 27 deletions

View File

@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix inability to use a named lifetime for `&PyTuple` of `*args` in `#[pyfunction]`. [#1440](https://github.com/PyO3/pyo3/pull/1440) - Fix inability to use a named lifetime for `&PyTuple` of `*args` in `#[pyfunction]`. [#1440](https://github.com/PyO3/pyo3/pull/1440)
- Fix inability to add `#[text_signature]` to some `#[pyproto]` methods. [#1483](https://github.com/PyO3/pyo3/pull/1483) - Fix inability to add `#[text_signature]` to some `#[pyproto]` methods. [#1483](https://github.com/PyO3/pyo3/pull/1483)
- Fix use of Python argument for #[pymethods] inside macro expansions. [#1505](https://github.com/PyO3/pyo3/pull/1505) - Fix use of Python argument for #[pymethods] inside macro expansions. [#1505](https://github.com/PyO3/pyo3/pull/1505)
- Always use cross-compiling configuration if any of the environment variables are set. [#1514](https://github.com/PyO3/pyo3/pull/1514)
## [0.13.2] - 2021-02-12 ## [0.13.2] - 2021-02-12
### Packaging ### Packaging

View File

@ -151,6 +151,12 @@ impl CrossCompileConfig {
} }
fn cross_compiling() -> Result<Option<CrossCompileConfig>> { fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
if env::var_os("PYO3_CROSS").is_none()
&& env::var_os("PYO3_CROSS_LIB_DIR").is_none()
&& env::var_os("PYO3_CROSS_INCLUDE_DIR").is_none()
&& env::var_os("PYO3_CROSS_VERSION").is_none()
&& env::var_os("PYO3_CROSS_PYTHON_VERSION").is_none()
{
let target = env::var("TARGET")?; let target = env::var("TARGET")?;
let host = env::var("HOST")?; let host = env::var("HOST")?;
if target == host { if target == host {
@ -167,6 +173,7 @@ fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
// Not cross-compiling to compile for x86-64 Python from macOS arm64 // Not cross-compiling to compile for x86-64 Python from macOS arm64
return Ok(None); return Ok(None);
} }
if target == "aarch64-apple-darwin" && host == "x86_64-apple-darwin" { if target == "aarch64-apple-darwin" && host == "x86_64-apple-darwin" {
// Not cross-compiling to compile for arm64 Python from macOS x86_64 // Not cross-compiling to compile for arm64 Python from macOS x86_64
return Ok(None); return Ok(None);
@ -182,6 +189,7 @@ fn cross_compiling() -> Result<Option<CrossCompileConfig>> {
// e.g. x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu host // e.g. x86_64-unknown-linux-musl on x86_64-unknown-linux-gnu host
return Ok(None); return Ok(None);
} }
}
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" { if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
// Windows cross-compile uses both header includes and sysconfig // Windows cross-compile uses both header includes and sysconfig