-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
python3Packages.*Hook: support __structuredAttrs = true
(the easier ones)
#351734
python3Packages.*Hook: support __structuredAttrs = true
(the easier ones)
#351734
Conversation
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.
Just read through, so far. Now we need packages that actually make use of those flags and test them with structuredAttrs and without:
pipBuildFlags
... is not used at all, so no useful package to test.pipInstallFlags
.. used 3 times, but only with a single flag. Not useful to test.pypaBuildFlags
could be tested withpillow-jpls
. This should fail with structuredAttrs on master/staging, if I'm not mistaken, but pass with structuredAttrs in this PR.pythonImportsCheck
should be tested carefully with one of the many packages that has multiple items set. This would likely fail silently with structuredAttrs on master/staging, only testing the first list item, but would test all of them with this branch.pythonNamespaces
also needs to be checked manually, to confirm the cleanup was in fact broken when multiple namespaces were given with structuredAttrs, but is fixed now.pythonRelaxDeps
andpythonRemoveDeps
should equally be tested manually - the build with structuredAttrs would probably not outright fail, yet, but the metadata file be subtly broken. Should be fixed with this branch.
pkgs/development/interpreters/python/hooks/setuptools-rust-hook.sh
Outdated
Show resolved
Hide resolved
pkgs/development/python-modules/meson-python/add-build-flags.sh
Outdated
Show resolved
Hide resolved
pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
Outdated
Show resolved
Hide resolved
pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
Outdated
Show resolved
Hide resolved
How about adding some packages to the
In my experience, |
85eb2d1
to
591bd1b
Compare
591bd1b
to
1221fc2
Compare
Cc: @bcdarwin ( |
Update:
This line is also in the build log of Submitting #352042 to fix this. |
Right. And with
Hm, I think the most valuable part to test for me is, to confirm that a package fails on master currently with structuredAttrs - but then passes with structuredAttrs on this branch. This needs to be tested manually anyway, to confirm the package broke before. So I don't see much point in adding those passthru.tests right now, if the idea is to eventually switch to "build everthing with structuredAttrs by default". Because then, this will be tested already, but we will surely forget to remove the passthru tests. |
I don't understand that, yet. Here's what I understand about the challenge with structuredAttrs:
So |
I tested it and now I understand what you mean: Because the python code accesses this variable as an environment variable it works without structuredAttrs. But with structuredAttrs this is not an exported environment variable anymore, but just a bash variable - thus python can't read it, and the imports check fails indeed. |
Exactly. The previous implementation of |
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 tested all commits, they do what they claim to do - fix those hooks with structuredAttrs turned on.
While the sum of changes is good, the split across commits is still not 100% clean. For some hooks shellcheck and structuredAttrs changes claim to be split between two commits, but the structuredAttrs commit contains part of the shellcheck changes.
The first commit should better be treewide:
and fix the remaining cases of that the *Phases+=
pattern as well.
The namespace hook should be a single shellcheck-only commit.
Other than that - it works.
1221fc2
to
14639c3
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.
This needs a rebase for the base branch to evaluate.
LGTM otherwise!
Thanks for pushing structuredAttrs :)
pkgs/development/interpreters/python/hooks/python-remove-tests-dir-hook.sh
Outdated
Show resolved
Hide resolved
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 looks good and indeed easy to me! Some questions to make sure I understand everything fully.
|
||
pipInstallPhase() { | ||
echo "Executing pipInstallPhase" | ||
runHook preInstall | ||
|
||
# shellcheck disable=SC2154 |
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 blocking, but: would be nice to do a trick like that /dev/null
thing to get declarations of all these essential variables.
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.
The /dev/null
/ source stuff was there before, see my reasoning in #351734 (comment) for removing it for now.
mkdir -p $out/src/my_project | ||
cp ${pyprojectToml} $out/pyproject.toml | ||
touch $out/src/__init__.py | ||
touch $out/src/my_project/__init__.py |
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.
Is this needed, or just general clean‐up of the example?
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 change makes it closer to how an actual project would be structured. The resulting package after this change could be Python-imported like import my_project
.
Such change is not strictly necessary to build the test anyway.
pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
Outdated
Show resolved
Hide resolved
pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
Outdated
Show resolved
Hide resolved
pkgs/development/interpreters/python/hooks/python-remove-tests-dir-hook.sh
Outdated
Show resolved
Hide resolved
Should we merge this in the next couple days? |
I was waiting for @ShamrockLee to rebase per responses to review feedback before merging. |
Make the interation across pythonRelaxDeps and pythonRemoveDeps work regardless of __structuredAttrs.
Ignore SC2164 at this moment, as it will be gone when adding `set -e`.
5fca99b
to
6597b74
Compare
Rebased. |
LGTM, thanks! |
This are the easier, less controversial part of the effort to make
buildPythonPackage
andbuildPythonApplication
support both__structuredAttrs = true
andstructuredAttrs = false
.Each modified Bash script is linted with ShellCheck.
It also fixes some leftovers of #339117 among Python-related hooks.
Split from #347194
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.