Skip to content

Commit

Permalink
python3.pkgs.pypaBuildHook: fix conflicts via propagated inputs 2
Browse files Browse the repository at this point in the history
A follow up on #254547

As of now the hook still propagated `wheel` into the build environment which lead to a collision error as soon as any other version of wheel gets introduced as a dependency.

This makes the nixpkgs python infra more suitable for use with dynamic dependency versions like generated by 2nix tools.
  • Loading branch information
DavHau committed Jan 8, 2024
1 parent 82ec417 commit 34a1a47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkgs/development/interpreters/python/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ self: dontUse: with self;

let
inherit (python) pythonOnBuildForHost;
inherit (pkgs) runCommand;
pythonInterpreter = pythonOnBuildForHost.interpreter;
pythonSitePackages = python.sitePackages;
pythonCheckInterpreter = python.interpreter;
Expand Down Expand Up @@ -58,7 +57,6 @@ in {
pypaBuildHook = callPackage ({ makePythonHook, build, wheel }:
makePythonHook {
name = "pypa-build-hook.sh";
propagatedBuildInputs = [ wheel ];
substitutions = {
inherit build;
};
Expand All @@ -68,8 +66,8 @@ in {
# Such conflicts don't happen within the standard nixpkgs python package
# set, but in downstream projects that build packages depending on other
# versions of this hook's dependencies.
passthru.tests = import ./pypa-build-hook-test.nix {
inherit pythonOnBuildForHost runCommand;
passthru.tests = callPackage ./pypa-build-hook-tests.nix {
inherit pythonOnBuildForHost;
};
} ./pypa-build-hook.sh) {
inherit (pythonOnBuildForHost.pkgs) build;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# At least one dependency of `build` should be included here to
# keep the test meaningful
(mkConflict pythonOnBuildForHost.pkgs.tomli)
(mkConflict pythonOnBuildForHost.pkgs.wheel)
# setuptools is also needed to build the example project
pythonOnBuildForHost.pkgs.setuptools
];
Expand Down
7 changes: 7 additions & 0 deletions pkgs/development/python-modules/build/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
, pytest-rerunfailures
, pytest-xdist
, pytestCheckHook
, python3
, pythonOlder
, setuptools
, tomli
Expand Down Expand Up @@ -93,6 +94,12 @@ buildPythonPackage rec {
"build"
];

# Add the wheel dependency via a wrapper.
# DO NOT use propagatedBuildInputs to prevent leakage into the build env.
makeWrapperArgs = [
''--suffix PYTHONPATH : "${wheel}/${python3.sitePackages}"''
];

meta = with lib; {
mainProgram = "pyproject-build";
description = "Simple, correct PEP517 package builder";
Expand Down

0 comments on commit 34a1a47

Please sign in to comment.