summary refs log tree commit diff
path: root/pkgs/development/python-modules/bootstrap/build/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/bootstrap/build/default.nix')
-rw-r--r--pkgs/development/python-modules/bootstrap/build/default.nix33
1 files changed, 27 insertions, 6 deletions
diff --git a/pkgs/development/python-modules/bootstrap/build/default.nix b/pkgs/development/python-modules/bootstrap/build/default.nix
index 639d2e3292c..f4e49bd6560 100644
--- a/pkgs/development/python-modules/bootstrap/build/default.nix
+++ b/pkgs/development/python-modules/bootstrap/build/default.nix
@@ -7,12 +7,15 @@
 , packaging
 , pyproject-hooks
 , tomli
+, makeWrapper
 }:
 let
   buildBootstrapPythonModule = basePackage: attrs: stdenv.mkDerivation ({
     pname = "${python.libPrefix}-bootstrap-${basePackage.pname}";
     inherit (basePackage) version src meta;
 
+    nativeBuildInputs = [ makeWrapper ];
+
     buildPhase = ''
       runHook preBuild
 
@@ -38,12 +41,30 @@ let
   bootstrap-pyproject-hooks = buildBootstrapPythonModule pyproject-hooks {};
 
   bootstrap-tomli = buildBootstrapPythonModule tomli {};
+
+  sitePkgs = python.sitePackages;
 in
 buildBootstrapPythonModule build {
-  propagatedBuildInputs = [
-    bootstrap-packaging
-    bootstrap-pyproject-hooks
-  ] ++ lib.optionals (python.pythonOlder "3.11") [
-    bootstrap-tomli
-  ];
+  # like the installPhase above, but wrapping the pyproject-build command
+  #   to set up PYTHONPATH with the correct dependencies.
+  # This allows using `pyproject-build` without propagating its dependencies
+  #   into the build environment, which is necessary to prevent
+  #   pythonCatchConflicts from raising false positive alerts.
+  # This would happen whenever the package to build has a dependency on
+  #   another version of a package that is also a dependency of pyproject-build.
+  installPhase = ''
+    runHook preInstall
+
+    PYTHONPATH="${installer}/${python.sitePackages}" \
+      ${python.interpreter} -m installer \
+        --destdir "$out" --prefix "" dist/*.whl
+
+    wrapProgram $out/bin/pyproject-build \
+      --prefix PYTHONPATH : "$out/${sitePkgs}" \
+      --prefix PYTHONPATH : "${bootstrap-pyproject-hooks}/${sitePkgs}" \
+      --prefix PYTHONPATH : "${bootstrap-packaging}/${sitePkgs}" \
+      --prefix PYTHONPATH : "${bootstrap-tomli}/${sitePkgs}"
+
+    runHook postInstall
+  '';
 }