-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check 'python-inconsistent-interpreters'
- Loading branch information
Showing
7 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ builtAttrs | ||
, packageSet | ||
, namePositions | ||
}@attrs: | ||
|
||
final: prev: | ||
let | ||
inherit (prev) lib; | ||
inherit (import ../lib { inherit lib; }) checkBuildPythonPackageFor; | ||
|
||
checkDerivation = drvArgs: drv: | ||
let | ||
propagatedBuildInputs = drvArgs.propagatedBuildInputs or []; | ||
checkInputs = drvArgs.checkInputs or []; | ||
runtimeInputs = checkInputs ++ propagatedBuildInputs; | ||
inputPythonInterpreters = map (p: p.pythonModule) (builtins.filter (p: p ? pythonModule) runtimeInputs); | ||
allPythonInterpreters = lib.unique (inputPythonInterpreters ++ [drv.pythonModule]); | ||
in | ||
lib.singleton { | ||
name = "python-inconsistent-interpreters"; | ||
cond = lib.length allPythonInterpreters > 1; | ||
msg = let | ||
allPythonNames = map (p: p.name) allPythonInterpreters; | ||
sources = ["buildPythonPackage"] ++ | ||
(lib.optionals ((lib.length propagatedBuildInputs) > 0) ["propagatedBuildInputs"]) ++ | ||
(lib.optionals ((lib.length checkInputs) > 0) ["checkInputs"]); | ||
in | ||
'' | ||
Between ${lib.concatStringsSep " and " sources}, this derivation seems | ||
to be simultaneously trying to use packages from multiple different python package sets. | ||
Mixing package sets like this is not supported. | ||
Detected pythons: | ||
${lib.concatStringsSep "\n " allPythonNames} | ||
''; | ||
}; | ||
in | ||
checkBuildPythonPackageFor checkDerivation attrs final prev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ callPackage | ||
}: | ||
|
||
{ | ||
# positive cases | ||
mixed-1 = callPackage ./mixed-1.nix { }; | ||
mixed-2 = callPackage ./mixed-2.nix { }; | ||
|
||
# negative cases | ||
normal = callPackage ./normal.nix { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ buildPythonPackage | ||
, python37Packages | ||
, python39Packages | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "package"; | ||
|
||
propagatedBuildInputs = [ python37Packages.numpy python39Packages.scipy ]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ buildPythonPackage | ||
, python27Packages | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "package"; | ||
|
||
checkInputs = [ python27Packages.numpy ]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ buildPythonPackage | ||
, numpy | ||
, scipy | ||
}: | ||
|
||
buildPythonPackage rec { | ||
pname = "package"; | ||
|
||
propagatedBuildInputs = [ numpy scipy ]; | ||
} | ||
|