From 793cc9d982415b71cdba729cf779bfc49e9d2ae7 Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 26 Jul 2023 04:19:19 +0300 Subject: [PATCH] python3: splice python within python3Packages.callPackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `lib.extends hooks pythonPackagesFun` includes python which we want to splice what this fixes: ``` nix-repl> lib.elemAt pkgsCross.aarch64-multiplatform.python3Packages.xpybutil.nativeBuildInputs 0 «derivation /nix/store/39dkb51rciw6zwg0c2c44gpmpjapddxc-python3-aarch64-unknown-linux-gnu-3.10.12.drv» ``` to ``` nix-repl> lib.elemAt pkgsCross.aarch64-multiplatform.python3Packages.xpybutil.nativeBuildInputs 0 «derivation /nix/store/21ldw2dp26xvv9iyxn9x77a8yh4waqz5-python3-3.10.12.drv» ``` Before https://github.com/NixOS/nixpkgs/pull/194205 The keep python used to work by accident because self was passed from __splicedPackages https://github.com/NixOS/nixpkgs/pull/196052/files#diff-44ce3495c4f983ce64dd47c86a9d3e77bad210b2709c098a3806998dcd9b000bR213 But now it does not work because overrideAttrs is used on python in python-packages-base.nix Preferably we would [ splice the hooks too ](https://github.com/NixOS/nixpkgs/pull/228139) but we cannot do that until [Package sets within derivations (i.e. python3.pkgs) are not spliced](https://github.com/NixOS/nixpkgs/issues/211340) is fixed, because people often use `python3.pkgs.wrapPython` in `nativeBuildInputs` (it's correct but python3.pkgs should be python3Packages to get splicing. --- pkgs/development/interpreters/python/hooks/default.nix | 8 ++++---- pkgs/development/interpreters/python/passthrufun.nix | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 001e477b9185b..338e15f02485b 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -1,9 +1,9 @@ -self: super: with self; +self: dontUse: with self; let - pythonInterpreter = super.python.pythonForBuild.interpreter; - pythonSitePackages = super.python.sitePackages; - pythonCheckInterpreter = super.python.interpreter; + pythonInterpreter = python.pythonForBuild.interpreter; + pythonSitePackages = python.sitePackages; + pythonCheckInterpreter = python.interpreter; setuppy = ../run_setup.py; in { makePythonHook = args: pkgs.makeSetupHook ({passthru.provides.setupHook = true; } // args); diff --git a/pkgs/development/interpreters/python/passthrufun.nix b/pkgs/development/interpreters/python/passthrufun.nix index aa63f354e085d..b73885b5e29e1 100644 --- a/pkgs/development/interpreters/python/passthrufun.nix +++ b/pkgs/development/interpreters/python/passthrufun.nix @@ -47,12 +47,13 @@ selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget. }; hooks = import ./hooks/default.nix; - keep = lib.extends hooks pythonPackagesFun; + keep = self: hooks self {}; extra = _: {}; optionalExtensions = cond: as: lib.optionals cond as; pythonExtension = import ../../../top-level/python-packages.nix; python2Extension = import ../../../top-level/python2-packages.nix; extensions = lib.composeManyExtensions ([ + hooks pythonExtension ] ++ (optionalExtensions (!self.isPy3k) [ python2Extension @@ -64,7 +65,7 @@ otherSplices keep extra - (lib.extends (lib.composeExtensions aliases extensions) keep)) + (lib.extends (lib.composeExtensions aliases extensions) pythonPackagesFun)) { overrides = packageOverrides; python = self;