From 60a0db675e8c3dd01672140f45f77975d9a410d7 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 11 Apr 2021 22:45:08 +0100 Subject: [PATCH] build: restore PYO3_CROSS variable --- build.rs | 3 ++- guide/src/building_and_distribution.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a911341958a..2d82942ffb9 100644 --- a/build.rs +++ b/build.rs @@ -145,7 +145,8 @@ fn cross_compiling() -> Result> { let target_vendor = cargo_env_var("CARGO_CFG_TARGET_VENDOR"); let target_os = cargo_env_var("CARGO_CFG_TARGET_OS"); - if cross_lib_dir.is_none() && cross_python_version.is_none() { + if env_var("PYO3_CROSS").is_none() && cross_lib_dir.is_none() && cross_python_version.is_none() + { // No cross-compiling environment variables set; try to determine if this is a known case // which is not cross-compilation. diff --git a/guide/src/building_and_distribution.md b/guide/src/building_and_distribution.md index aafbe341d3c..b595081e8cc 100644 --- a/guide/src/building_and_distribution.md +++ b/guide/src/building_and_distribution.md @@ -90,6 +90,7 @@ See [github.com/japaric/rust-cross](https://github.com/japaric/rust-cross) for a After you've obtained the above, you can build a cross compiled PyO3 module by setting a few extra environment variables: +* `PYO3_CROSS`: If present this variable forces PyO3 to configure as a cross-compilation. * `PYO3_CROSS_LIB_DIR`: This variable must be set to the directory containing the target's libpython DSO and the associated `_sysconfigdata*.py` file for Unix-like targets, or the Python DLL import libraries for the Windows target. * `PYO3_CROSS_PYTHON_VERSION`: Major and minor version (e.g. 3.9) of the target Python installation. This variable is only needed if PyO3 cannot determine the version to target from `abi3-py3*` features, or if there are multiple versions of Python present in `PYO3_CROSS_LIB_DIR`.