python3Packages.setuptools-rust: fix python version inconsistency (#473299)

This commit is contained in:
Aleksana
2025-12-23 03:27:20 +00:00
committed by GitHub
2 changed files with 14 additions and 15 deletions
@@ -141,7 +141,13 @@ rec {
pythonAtLeast = lib.versionAtLeast pythonVersion;
pythonOlder = lib.versionOlder pythonVersion;
inherit hasDistutilsCxxPatch;
inherit pythonOnBuildForHost;
inherit
pythonOnBuildForBuild
pythonOnBuildForHost
pythonOnBuildForTarget
pythonOnHostForHost
pythonOnTargetForTarget
;
inherit pythonABITags;
tests = callPackage ./tests.nix {
@@ -13,6 +13,7 @@
setuptools-rust,
setuptools-scm,
replaceVars,
python,
targetPackages,
}:
buildPythonPackage rec {
@@ -44,20 +45,12 @@ buildPythonPackage rec {
# integrate the setup hook to set up the build environment for cross compilation
# this hook is automatically propagated to consumers using setuptools-rust as build-system
#
# Only include the setup hook if targetPackages.python3 is defined.
# targetPackages.python3 is not always available, for example when including
# setuptools-rust via buildInputs instead of nativeBuildInputs or building it directly.
setupHook =
if !(targetPackages ? python3) then
null
else
replaceVars ./setuptools-rust-hook.sh {
pyLibDir = "${targetPackages.python3}/lib/${targetPackages.python3.libPrefix}";
cargoBuildTarget = stdenv.targetPlatform.rust.rustcTargetSpec;
cargoLinkerVar = stdenv.targetPlatform.rust.cargoEnvVarTarget;
targetLinker = "${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc";
};
setupHook = replaceVars ./setuptools-rust-hook.sh {
pyLibDir = "${python.pythonOnTargetForTarget}/lib/${python.pythonOnTargetForTarget.libPrefix}";
cargoBuildTarget = stdenv.targetPlatform.rust.rustcTargetSpec;
cargoLinkerVar = stdenv.targetPlatform.rust.cargoEnvVarTarget;
targetLinker = "${targetPackages.stdenv.cc}/bin/${targetPackages.stdenv.cc.targetPrefix}cc";
};
passthru.tests = {
pyo3 = maturin.tests.pyo3.override {