-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
buildPythonPackage, buildPythonApplication: make doCheck default less confusing #308377
Conversation
@ShamrockLee, thanks for this. Apologies if my confusion about around the Also: should this information about what ( |
I think this is the classic mistake of expecting the Example: # a.nix
{ a ? "foo" }@attrs:
attrs.a or "bar" When doing |
Here's the change that broke/changed the old default of |
We could also set |
I haven't inspect into the reason why it is enabled by default. The design choice has been made years ago. What I'm doing in this PR is to uncover it. Besides, defaulting
It would be great to explain them in the Nixpkgs Manual. However, I plan to propose setting it directly via |
Thanks a lot for finding it out! (#68244)
According to the documentation, |
Oh, I see. I didn't see that it was set by default. I expected it to be this way, because every place that mentions this config option has an |
Python tests have always been enabled because it is otherwise very hard to
judge during build time whether the package will work at all.
…On Sun, May 5, 2024, 01:44 Toma ***@***.***> wrote:
@TomaSajt <https://github.com/TomaSajt>
Here's the change that broke/changed the old default of false to true:
f7e28bf
<f7e28bf>
Thanks a lot for finding it out! (#68244
<#68244>)
We could also set config.doCheckByDefault or true as the default, so that
it starts respecting the config value again. This should not cause
rebuilds, unless you have the config set to false, but then you're
probably always expecting massive rebuilds anyway.
According to the documentation
<https://nixos.org/manual/nixpkgs/unstable/#opt-doCheckByDefault>,
config.doCheckByDefault is "default to false", and "changing the default
may cause a mass rebuild." AFAIK, it is unexpected for doCheckByDefault =
false to cause rebuild.
Oh, I see. I didn't see that it was set by default.
I thought the docs would be something like: "either set this to true/false
to force it to be true/false, or don't set it to leave the choice to the
builder helpers".
—
Reply to this email directly, view it on GitHub
<#308377 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQHZ3Y22OESB5N55DNN4CLZAVXFNAVCNFSM6AAAAABHCTZE5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJUGUYDGMJZGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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.
With the information provided and my current understanding, I support this change. Someone more knowledgable may disagree and hopefully they decide to speak up and share their insight.
Thank you for putting this together, @ShamrockLee, much appreciated! And thank you everyone else for chiming in with your expertise.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-already-reviewed/2617/1756 |
@JohnRTitor would you be willing to lend your expertise for review and if acceptable merge this PR? |
@@ -309,7 +309,8 @@ let | |||
|
|||
# Python packages don't have a checkPhase, only an installCheckPhase | |||
doCheck = false; | |||
doInstallCheck = attrs.doCheck or true; | |||
# The doCheck argument determines the doInstallCheck attribute. | |||
doInstallCheck = doCheck; |
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.
doInstallCheck = doCheck; | |
doInstallCheck = attrs.doCheck; |
Could you clarify this with attrs
?
I think it is confusing since there is a doCheck = false
right above it.
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.
Can't test it right now, but IIRC if we use the @attrs
pattern, the defaults set with ?
will not be applied when accessing through attrs.
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.
Could you clarify this with
attrs
?
attrs
does not consider the default value given by the set pattern of the build helper. It would be confusing to set a default value in the set pattern ({ doCheck ? true, ... }
) but shadow it with another default when accessing (doInstallCheck = attrs.doCheck or true
).
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.
Hmmm, indeed, attrs
seems to be empty, as @TomaSajt pointed out at the beginning.
Then I think attrs.doCheck or true
would be easier to understand.
The confusion was originally caused by the fact that the argument, doCheck
, actually evaluates to true even though it defaults to false, right?
Do we need to change this here?
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.
Hmmm, indeed,
attrs
seems empty, as @TomaSajt pointed out at the beginning. Then I thinkattrs.doCheck or true
would be easier to understand.
It still shadows the default set by the set pattern, but it sounds like an acceptable trade-off, considering the increased readability.
IMO, the root cause of the readability issue is the choice to specify the doInstallCheck
attribute with the doCheck
argument. In subsequent PR, I propose unifying the name (as doInstallCheck
).
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.
Addressed.
@@ -309,7 +309,8 @@ let | |||
|
|||
# Python packages don't have a checkPhase, only an installCheckPhase | |||
doCheck = false; | |||
doInstallCheck = attrs.doCheck or true; | |||
# The doCheck argument determines the doInstallCheck attribute. |
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 comment explains what it does, but I don't think it's necessary because it's just what the code says.
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.
Addressed.
ced9eeb
to
60cfc1e
Compare
Modify the set pattern to hint developers that the doInstallCheck attribute of Python packages, specified by the doCheck argument of buildPythonPackage and buildPythonApplication, defaults to true instead of false.
60cfc1e
to
455314a
Compare
I just rebased it onto the tip of the |
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.
Thanks for improving this. LGTM
Thanks for merging. I created another PR #324124 proposing directly taking the |
@@ -144,7 +144,7 @@ in | |||
|
|||
, meta ? {} | |||
|
|||
, doCheck ? config.doCheckByDefault or false | |||
, doCheck ? true |
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's a bit late now, but I think this fix was not the one that needed to happen, since doCheck
never gets used.
Only attrs.doCheck
is ever referenced, which doesn't need this line.
, doCheck ? true |
Should we open another PR that just removes this line?
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.
Ah, yes. Removing this line from the set pattern is a better solution to such confusion.
Description of changes
Make it clear that argument doCheck of buildPythonPackage and buildPythonApplication defaults to true instead of false.
(For context, see #307838 (comment))
The current implementation of
mk-python-derivation.nix
appears to defaultdoCheck
config.doCheckByDefault or false
, but effectively default ittrue
.This PR resolves such confusion:
Another confusion caused by argument
doCheck
determining attributedoInstallCheck
should be resolved by instructing people to specifydoInstallCheck
instead ofdoCheck
andinstallCheckPhase
instead ofcheckPhase
. That's a change of interface that needs more discussion, and is excluded from the scope of this PR.This PR is a back-portable fix that brings no interface changes and no rebuilds.
Cc: @FRidh @afh
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.