python3Packages.*Hook: support __structuredAttrs = true (the easier ones)#351734
Conversation
wolfgangwalther
left a comment
There was a problem hiding this comment.
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.pypaBuildFlagscould be tested withpillow-jpls. This should fail with structuredAttrs on master/staging, if I'm not mistaken, but pass with structuredAttrs in this PR.pythonImportsCheckshould 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.pythonNamespacesalso needs to be checked manually, to confirm the cleanup was in fact broken when multiple namespaces were given with structuredAttrs, but is fixed now.pythonRelaxDepsandpythonRemoveDepsshould 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/python-output-dist-hook.sh
Outdated
Show resolved
Hide resolved
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 |
wolfgangwalther
left a comment
There was a problem hiding this comment.
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.
pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
Outdated
Show resolved
Hide resolved
pkgs/development/interpreters/python/hooks/python-output-dist-hook.sh
Outdated
Show resolved
Hide resolved
1221fc2 to
14639c3
Compare
wolfgangwalther
left a comment
There was a problem hiding this comment.
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
emilazy
left a comment
There was a problem hiding this comment.
This looks good and indeed easy to me! Some questions to make sure I understand everything fully.
There was a problem hiding this comment.
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.
The /dev/null / source stuff was there before, see my reasoning in #351734 (comment) for removing it for now.
There was a problem hiding this comment.
Is this needed, or just general clean‐up of the example?
There was a problem hiding this comment.
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-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
buildPythonPackageandbuildPythonApplicationsupport both__structuredAttrs = trueandstructuredAttrs = 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 = relaxedsandbox = truenix-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.