Add setup_rust_cross_compile
This commit is contained in:
@@ -161,6 +161,7 @@ def setup_setuptools_cross_compile(
|
|||||||
# interpreter, and has no logic to construct it. Currently, CPython's
|
# interpreter, and has no logic to construct it. Currently, CPython's
|
||||||
# extensions follow our identifiers, but if they ever diverge in the
|
# extensions follow our identifiers, but if they ever diverge in the
|
||||||
# future, we will need to store new data
|
# future, we will need to store new data
|
||||||
|
log.info("Setting SETUPTOOLS_EXT_SUFFIX=.%s.pyd for cross-compilation", python_configuration.identifier)
|
||||||
env["SETUPTOOLS_EXT_SUFFIX"] = f".{python_configuration.identifier}.pyd"
|
env["SETUPTOOLS_EXT_SUFFIX"] = f".{python_configuration.identifier}.pyd"
|
||||||
|
|
||||||
# Cross-compilation requires fixes that only exist in setuptools's copy of
|
# Cross-compilation requires fixes that only exist in setuptools's copy of
|
||||||
@@ -171,6 +172,35 @@ def setup_setuptools_cross_compile(
|
|||||||
env["SETUPTOOLS_USE_DISTUTILS"] = "local"
|
env["SETUPTOOLS_USE_DISTUTILS"] = "local"
|
||||||
|
|
||||||
|
|
||||||
|
def setup_rust_cross_compile(
|
||||||
|
python_configuration: PythonConfiguration,
|
||||||
|
python_libs_base: Path,
|
||||||
|
env: Dict[str, str],
|
||||||
|
) -> None:
|
||||||
|
# Assume that MSVC will be used, because we already know that we are
|
||||||
|
# cross-compiling. MinGW users can set CARGO_BUILD_TARGET themselves
|
||||||
|
# and we will respect the existing value.
|
||||||
|
cargo_target = {
|
||||||
|
"64": "x86_64-pc-windows-msvc",
|
||||||
|
"32": "i686-pc-windows-msvc",
|
||||||
|
"ARM64": "aarch64-pc-windows-msvc",
|
||||||
|
}.get(python_configuration.arch)
|
||||||
|
|
||||||
|
# CARGO_BUILD_TARGET is the variable used by Cargo and setuptools_rust
|
||||||
|
if env.get("CARGO_BUILD_TARGET"):
|
||||||
|
if env["CARGO_BUILD_TARGET"] != cargo_target:
|
||||||
|
log.warning("Not overriding CARGO_BUILD_TARGET as it has already been set")
|
||||||
|
# No message if it was set to what we were planning to set it to
|
||||||
|
elif cargo_target:
|
||||||
|
log.info("Setting CARGO_BUILD_TARGET=%s for cross-compilation", cargo_target)
|
||||||
|
env["CARGO_BUILD_TARGET"] = cargo_target
|
||||||
|
else:
|
||||||
|
log.warning(
|
||||||
|
"Unable to configure Rust cross-compilation for architecture '%s'",
|
||||||
|
python_configuration.arch
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_python(
|
def setup_python(
|
||||||
tmp: Path,
|
tmp: Path,
|
||||||
python_configuration: PythonConfiguration,
|
python_configuration: PythonConfiguration,
|
||||||
@@ -299,6 +329,7 @@ def setup_python(
|
|||||||
if python_libs_base:
|
if python_libs_base:
|
||||||
# Set up the environment for various backends to enable cross-compilation
|
# Set up the environment for various backends to enable cross-compilation
|
||||||
setup_setuptools_cross_compile(python_configuration, python_libs_base, env)
|
setup_setuptools_cross_compile(python_configuration, python_libs_base, env)
|
||||||
|
setup_rust_cross_compile(python_configuration, python_libs_base, env)
|
||||||
|
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user