New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mkPythonDerivation: validate propagatedBuildInputs and buildInputs use a matching python #120220
Conversation
384f1c1
to
b9c8d5b
Compare
a13e85d
to
85b19a5
Compare
c580db8
to
5c4b982
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
In principle I should say yes, because this will lead to mistakes. A potential, but bad case, is where one wants to rely on
Until someone reports a valid case where it is needed, I don't think we should.
This is sufficient I think. |
Note if it would block to build, it would need an entry in the changelog. |
nit: propogatedBuildInputs --> propagatedBuildInputs in the PR subject |
|
5c4b982
to
62f3120
Compare
This PR has an updated message, and uses throw now:
|
It now blocks the build, @FRidh. Which changelog do you mean? NixOS? Nixpkgs hasn't really had a changelog in years. |
Yes, NixOS, so it is add least findable without having to resort to
|
This one is tricky, we don't actually know what the attribute name of the derivation named 'flake8', and I'm not sure how to word this otherwise. |
I noticed the same when working on error messages on |
How about an ofborg check that really wants pname == attrname |
Current error looks ilke:
|
Looks great to me!
That would also need to consider variants, which would then be forced to fix their
That seems like a good idea. A problematic case would be Python packages. Their |
Agreed, I don't think it would be reasonable to ensure pname == attrname. It might be a useful lint as part of a "packaging health report", though... Not sure. Something like this would be advisory, not errory. |
Yes please. or nixpkgs-hammering. |
Any chance we can land this? The error looks good - I think we might want to file a followup issue against OfBorg for the pname==attrname check. |
I marked this as stale due to inactivity. → More info |
Can I do something to help get this merged? |
11a5f56
to
4de2076
Compare
len = lib.max (lib.stringLength name) (lib.stringLength against); | ||
in lib.strings.fixedWidthString len " " name; | ||
|
||
drvName = drv: drv.pname or drv.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either this should just be .name or both should use lib.getName, depends on if we want versions
error: Python version mismatch in 'xpybutil-0.0.6':
The Python derivation 'xpybutil-0.0.6' depends on a Python derivation
named 'xpybutil', but the two derivations use different versions
of Python:
'xpybutil-0.0.6' uses /nix/store/fdqpyj613dr0v1l1lrzqhzay7sk4xg87-python3-3.10.10
'xpybutil' uses /nix/store/v7h4276ij0sj48qwrf4g4cm3pfc86mmw-python3-3.9.16
Possible solutions:
* If 'xpybutil' is a Python library, change the reference to 'xpybutil'
in the propagatedBuildInputs of 'xpybutil-0.0.6' to use a 'xpybutil' built from the same
version of Python
* If 'xpybutil' is used as a tool during the build, move the reference to
'xpybutil' in 'xpybutil-0.0.6' from propagatedBuildInputs to nativeBuildInputs
* If 'xpybutil' provides executables that are called at run time, pass its
bin path to makeWrapperArgs:
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ xpybutil ] }" ];
diff --git a/pkgs/development/python-modules/xpybutil/default.nix b/pkgs/development/python-modules/xpybutil/default.nix
index cc574c58241..9236df77d84 100644
--- a/pkgs/development/python-modules/xpybutil/default.nix
+++ b/pkgs/development/python-modules/xpybutil/default.nix
@@ -1,4 +1,4 @@
-{ lib, buildPythonPackage, fetchFromGitHub, xcffib, pillow }:
+{ lib, buildPythonPackage, fetchFromGitHub, xcffib, pillow, python39 }:
buildPythonPackage rec {
pname = "xpybutil";
@@ -13,7 +13,7 @@ buildPythonPackage rec {
};
# pillow is a dependency in image.py which is not listed in setup.py
- propagatedBuildInputs = [ pillow xcffib ];
+ propagatedBuildInputs = [ pillow xcffib python39.pkgs.xpybutil ];
propagatedNativeBuildInputs = [ xcffib ];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to .name and the suggestion below to lib.getName
4de2076
to
6284642
Compare
6284642
to
8ce82e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested this but the change looks good.
mkPythonDerivation: apply checks to buildInputs as well fixup: add a suggestion about nativeBuildInputs Clean up the wording, add reasons for the suggestions switch to throw Adjust error to clarify build-time vs. run-time
8ce82e3
to
d44390a
Compare
|
neat! |
It isn't so difficult to accidentally mix and match Python packages from different pythons. This can cause fairly mysterious build time and run time errors. This PR adds a trace-only warning:
which will prevent these mistakes from entering Nixpkgs but only present as a nuisance for users outside of nixpkgs.
Open questions for me:
This has been made on behalf of Flox.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)