-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add support for buildPythonPackage #15
Conversation
inherit (import ../lib { inherit lib; }) checkFor; | ||
|
||
incorrectSpellings = [ | ||
"pythonImportTests" |
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.
This will never be a complete list and is a deeper issue in nix. I don't want to start something with levenshtein because a good reviewer should catch that.
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.
Adding a levehnstein checker is on my to do list since typos are common and tooling should catch them. Example from today https://discourse.nixos.org/t/error-building-python-package-no-matching-distribution-found-could-not-find-a-version-that-satisfies-the-requirement-six/11143
And adding synonyms is also a good idea IMHO (maybe we could even try to include it into levehnstein formula).
I have a few ideas if you are interested:
|
I think I'm actually hitting this bug/issue, and I'm not sure how to solve it yet: NixOS/nixpkgs#44426 |
Thanks for the hint. Let me bang my head against that for a bit. |
fb980f3
to
c64f442
Compare
This PR should be working now. I've force pushed and separated the commits into individual units. I'm new to this codebase, and fairly new to nix in general, so any feedback would be appreciated. I'm sure I'm messing some things up. Here's an example running with c64f442 and the new checks:
Producing the output
|
@SuperSandro2000 wrote:
I've implemented this in aa085cb, but the changes required are a little bigger to the code base, because it requires our checkDerivation functions knowing which interpreter version they're being called on. Making this consistent with the mkDerivation checks requires also changing those checks to get passed the relevant stdenv, I think. So this commit will require some code review, I think. I'd be happy to move it to a separate PR, if you prefer. |
Looks good at first glance, will give it a thorough review in the afternoon (CEST). Could you also add the test file to the |
Can't decide that because it is jtojnar projects. |
f0e6df4
to
8e92bd5
Compare
@jtojnar: I've added tests. |
|
||
Detected pythons: | ||
|
||
${lib.concatStringsSep "\n " allPythonNames} |
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.
It might be nice to name the offending packages. Though most of the time, they would probably be listed included using python*Packages
in the file so maybe it is unnecessary.
Do you feel like writing a short blurb for each check to add to |
bcefb64
to
66a97bf
Compare
I believe that I've fixed all of the more cosmetic changes in the last review, but I have not (yet) addressed the more substantive ones. |
d817f5d
to
f0a5c09
Compare
Rebase finished. |
57f1a16
to
a4b1062
Compare
lib/default.nix
Outdated
|
||
let | ||
pythonPackageSetNames = [ | ||
"python" |
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.
It would be better to generate this list automatically.
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.
Replacing this expression with pythonPackageSetNames = lib.attrNames prev.pythonInterpreters;
-- which seems like it absolutely should work(!) instead gives an infinite recursion error.
e393f9e
to
5b794b2
Compare
Turns out I made a mistake when writing the The following should work: diff --git a/lib/default.nix b/lib/default.nix
index 28abae1..97d2255 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -25,6 +25,9 @@ rec {
};
};
+ # Identity element for overlays.
+ idOverlay = final: prev: {};
+
# Creates a function based on the original one, that, when called on
# one of the requested packages, runs a check on the arguments passed to it
# and then returns the original result enriched with the reports.
@@ -101,16 +104,14 @@ rec {
in
lib.genAttrs pythonPackageSetNames (pythonName:
- let
- prvPython = builtins.getAttr pythonName prev;
- in prvPython.override {
- packageOverrides = python-self: python-super: {
- buildPythonPackage = wrapFunctionWithChecks prvPython.pkgs.buildPythonPackage namePositions check;
- };
- });
+ prev.${pythonName}.override (oldOverrides: {
+ packageOverrides = lib.composeExtensions (oldOverrides.packageOverrides or idOverlay) (final: prev: {
+ buildPythonPackage = wrapFunctionWithChecks prev.buildPythonPackage namePositions check;
+ });
+ }));
checkFor = check: let
o1 = (checkMkDerivationFor check);
o2 = (checkBuildPythonPackageFor check);
- in attrs: final: prev: (o1 attrs final prev) // (o2 attrs final prev);
+ in attrs: lib.composeExtensions (o1 attrs) (o2 attrs);
} |
Actually -- I need to bisect my changes a little bit. Something I've done has caused every error message do be repeated twice. I suspect that diff might be the problem... |
e631594
to
6fd4e8c
Compare
(The duplication is has been fixed by slapping in a call to lib.unique, based on @jtojnar's suggestion.) |
6fd4e8c
to
858178a
Compare
I think this is ready to go, pending writing explanations for each error message. Is there anything else that's a blocker for you, @jtojnar? |
Looks good to me otherwise. Great job. Unfortunately, I do not think I will be able to write the explanations this week after all. We can just add |
I added some explanations in fa77e76. Maybe you could take a look at them, @SuperSandro2000? |
fa77e76
to
995087b
Compare
@@ -0,0 +1,16 @@ | |||
Not all python packages include tests. However it should be possible, at a minimum, to "smoke test" every python package my simply checking that the modules it declares can be `import`ed. |
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.
Not all python packages include tests. However it should be possible, at a minimum, to "smoke test" every python package my simply checking that the modules it declares can be `import`ed. | |
Not all python packages include tests. However it should be possible, at a minimum, to "smoke test" every python package by simply checking that the modules it declares can be `import`ed. |
This should probably added to all python packages regardless of tests.
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.
Right now, the logic in the check only requires the package to have either a checkPhase or a pythonImportsCheck. Do you think it should be changed to require a pythonImportsCheck unconditionally?
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 am not completely sure but it does not hurt.
Since python3 and python39 are aliases, the checks are added multiple times to Python packages. Let’s deduplicate them.
3b82aee
to
e4d07f7
Compare
I have fixed some minor style issues, squashed the explanations into the introducing commits, added some links. I have also changed the wording of |
Thank you for this great job. |
Hi @jtojnar:
I've started trying to add support for checking the arguments to buildPythonPackage as an addition to the current checking of the arguments to mkDerivation. So far, it appears to mostly work, although I can't yet seem to get it to report multiple failures at once -- the checks appear to short-circuit once a single failing check is identified.
Still WIP, but I wanted to post this now for any feedback.