From ba02fd0434ed92b7335f17c97af689b9db1413e0 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 20 Apr 2022 21:20:50 +0200 Subject: [PATCH] python3: fix overriding of interpreters, closes #163639 Overriding the interpreters did not work correctly. When overriding packages would end up twice in the build time closure: one corresponding to the overridden interpreter and one corresponding to the original interpreter. The reason is that the override was not applied to the interpreters in the spliced package sets. --- .../interpreters/python/cpython/default.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 97db4a9fffa8..23c85942ad70 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -49,7 +49,7 @@ , enableLTO ? stdenv.is64bit && stdenv.isLinux , reproducibleBuild ? false , pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}" -}: +} @ inputs: # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or @@ -83,7 +83,10 @@ let tzdataSupport = tzdata != null && passthru.pythonAtLeast "3.9"; - passthru = passthruFun rec { + passthru = let + # When we override the interpreter we also need to override the spliced versions of the interpreter + override = attr: let python = attr.override (inputs // { self = python; }); in python; + in passthruFun rec { inherit self sourceVersion packageOverrides; implementation = "cpython"; libPrefix = "python${pythonVersion}"; @@ -91,11 +94,11 @@ let pythonVersion = with sourceVersion; "${major}.${minor}"; sitePackages = "lib/${libPrefix}/site-packages"; inherit hasDistutilsCxxPatch; - pythonOnBuildForBuild = pkgsBuildBuild.${pythonAttr}; - pythonOnBuildForHost = pkgsBuildHost.${pythonAttr}; - pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr}; - pythonOnHostForHost = pkgsHostHost.${pythonAttr}; - pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or {}; + pythonOnBuildForBuild = override pkgsBuildBuild.${pythonAttr}; + pythonOnBuildForHost = override pkgsBuildHost.${pythonAttr}; + pythonOnBuildForTarget = override pkgsBuildTarget.${pythonAttr}; + pythonOnHostForHost = override pkgsHostHost.${pythonAttr}; + pythonOnTargetForTarget = if lib.hasAttr pythonAttr pkgsTargetTarget then (override pkgsTargetTarget.${pythonAttr}) else {}; }; version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";