Skip to content

python3Packages: don't depend on setup hooks' bash eval#352976

Merged
emilazy merged 3 commits intoNixOS:stagingfrom
wolfgangwalther:no-python-eval-staging
Nov 15, 2024
Merged

python3Packages: don't depend on setup hooks' bash eval#352976
emilazy merged 3 commits intoNixOS:stagingfrom
wolfgangwalther:no-python-eval-staging

Conversation

@wolfgangwalther
Copy link
Contributor

This came up in #335110 and then in #347194.

The python ecosystem currently uses bash eval in some setup hooks - and of course some packages depend on that. Mostly in pytestFlagsArray, but also in setupPyBuildFlags and setupPyGlobalFlags.

This PR deals with all those cases, replacing it with more adequate solutions. This will allow us to replace pytestFlagsArray with a structuredAttrs-supporting pytestFlags alternative more easily later on.

@ShamrockLee @SomeoneSerge @emilazy @philiptaron

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 1, 2024
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 2, 2024
@SomeoneSerge
Copy link
Contributor

I see pytestFlagsArray mentioned and approve without looking xD

On a serious note, my opinion is we should not be changing the semantics of such an old variable, we need a new name, and maybe we deprecate the old with a warning.

I'm slightly concerned that with this and with the previous __structuredAttrs-related changes we're walking into the territory we might accidentally make composing expressions from different nixpkgs releases impossible. To my knowledge, we don't even use any versioning for the setup-hook system?

@wolfgangwalther
Copy link
Contributor Author

On a serious note, my opinion is we should not be changing the semantics of such an old variable, we need a new name, and maybe we deprecate the old with a warning.

Yes, that's the plan. The idea is to create a pytestFlags variable with proper structuredAttrs support now, then migrate all uses of pytestFlagsArray to pytestFlags, but keep pytestFlagsArray for a little longer in the old form.

This PR is just a preparation to make the change from pytestFlagsArray to pytestFlags easier to do - because all the special cases should have been dealt with already.


Regarding setupPyBuildFlags and setupPyGlobalFlags I think we can just break them after this PR is done. There were only one or two expressions depending on that behavior, so the blast radius should be very small here.

I'm slightly concerned that with this and with the previous __structuredAttrs-related changes we're walking into the territory we might accidentally make composing expressions from different nixpkgs releases impossible. To my knowledge, we don't even use any versioning for the setup-hook system?

Uhm, isn't that the case with every change to stdenv / any hook etc.? I think the expectation to be able to put an expression into a different nixpkgs version and have it work is unreasonable in the general case. Although... external overrides are exactly that, right? Hm....

@SomeoneSerge
Copy link
Contributor

SomeoneSerge commented Nov 2, 2024

external overrides are exactly that, right?

My thinking too. Overlays can access lib.version but there's little to no control over propagated stuff, including the hooks.

Uhm, isn't that the case with every change to stdenv / any hook etc

Yes. I'd reckon it's OK because we're rather conservative about touching stdenv and hooks (EDIT: isn't this how structuredAttrs still aren't the default?..). Which I reckon we are at least partly because we don't know how people might be (ab)using nixpkgs "internals" out-of-tree. We could know a tad more if we advertised a more explicit interface, e.g. versioning

@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 2, 2024
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 2, 2024
@Aleksanaa Aleksanaa changed the title pythonPackages: don't depend on setup hooks' bash eval python3Packages: don't depend on setup hooks' bash eval Nov 3, 2024
@ShamrockLee
Copy link
Contributor

@ofborg build picard
@ofborg build chipsec
@ofborg build fichub-cli
@ofborg build python311Packages.macaddress build python312Packages.macaddress
@ofborg build python311Packages.iso421 python312Packages.iso4217
@ofborg build python311Packages.certbot-dns-inwx python312Packages.certbot-dns-inwx
@ofborg build python311Packages.qcodes python312Packages.qcodes
@ofborg build conan
@ofborg build rountersploit
@ofborg build python311Packages.certbot-dns-cloudflare python312Packages.certbot-dns-cloudflare
@ofborg build python311Packages.certbot-dns-google python312Packages.certbot-dns-google
@ofborg build python311Packages.certbot-dns-ovh python312Packages.certbot-dns-ovh
@ofborg build python311Packages.certbot-dns-rfc2136 python312Packages.certbot-dns-rfc2136
@ofborg build python311Packages.certbot-dns-route53 python312Packages.certbot-dns-route53
@ofborg build python311Packages.certbot python312Packages.certbot
@ofborg build python311Packages.psycopg python312Packages.psycopg
@ofborg build python311Packages.dtw-python python312Packages.dtw-python
@ofborg build python311Packages.numcodecs python312Packages.numcodecs
@ofborg build python311Packages.bottleneck python312Packages.bottleneck
@ofborg build python311Packages.vapoursynth python312Packages.vapoursynth
@ofborg build python311Packages.pytest-xdist python312Packages.pytest-xdist
@ofborg build python311Packages.psutil python312Packages.psutil

Test pytest-xdist
@ofborg build dosage

@ShamrockLee
Copy link
Contributor

Oops! I didn't mean to DoS our CI 😓

@emilazy
Copy link
Member

emilazy commented Nov 3, 2024

but you explicitly asked for DoS‐age!

@ShamrockLee
Copy link
Contributor

python3Packages.certbot-dns-{cloudflare,ovh,rfc2136,route53} fails to build on master, complaining

DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use ...

I filed an issue in Nixpkgs (#354054). Such issue might also need to be upstreamed.

@wolfgangwalther
Copy link
Contributor Author

python3Packages.certbot-dns-{cloudflare,ovh,rfc2136,route53} fails to build on master, complaining

I think those could be fixed on staging already, but I might mis-remember.

@ShamrockLee
Copy link
Contributor

python3Packages.certbot-dns-{cloudflare,ovh,rfc2136,route53} fails to build on master, complaining

I think those could be fixed on staging already, but I might mis-remember.

We must check if they failed to build on master or staging since they failed after this change.

@wolfgangwalther
Copy link
Contributor Author

We must check if they failed to build on master or staging since they failed after this change.

Yeah, I didn't want to rebase while all the ofborg stuff was running, so might have been after where the branch is currently on.

@ShamrockLee
Copy link
Contributor

We must check if they failed to build on master or staging since they failed after this change.

Yeah, I didn't want to rebase while all the ofborg stuff was running, so might have been after where the branch is currently on.

Oops! I switched to the wrong commit. Now I'm waiting for the correct one to build.

@wolfgangwalther
Copy link
Contributor Author

Since this is causing a lot of rebuilds and thus is hard to test, I am thinking of splitting it up in two pieces - one going to master with everything that causes fewer rebuilds, and one part staying here, causing the big number of rebuilds, but possibly easier to review alone.

That is.. unless someone is already convinced that this PR is good to go? Then I'd just rebase over the trivial conflict in numcodecs.

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Nov 8, 2024

Since this is causing a lot of rebuilds and thus is hard to test, I am thinking of splitting it up in two pieces - one going to master with everything that causes fewer rebuilds, and one part staying here, causing the big number of rebuilds, but possibly easier to review alone.

Sounds great!

That is.. unless someone is already convinced that this PR is good to go? Then I'd just rebase over the trivial conflict in numcodecs.

These changes looks good for me. Considering those extra flags and pre/post steps contain package-specific tricks to make them build, it's still safer to at least test if they build successfully.

Hope we could land this series of changes onto Nixpkgs 24.11. Update: I'm not sure about this one. It seems backward-compatible anyway.

…ldFlags

We'd like to remove bash eval for setupByBuildFlags, thus use
appendToVar in the hook instead.

Tested that linuxPackages.chipsec still builds, including the driver in
the right place.
@ofborg ofborg bot added 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. and removed 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 10, 2024
Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Nov 10, 2024
@wolfgangwalther
Copy link
Contributor Author

@ShamrockLee After the other PRs have been merged, shall we continue with this one? I think this should be good to go, do you agree?

@ShamrockLee
Copy link
Contributor

ShamrockLee commented Nov 15, 2024 via email

@wolfgangwalther
Copy link
Contributor Author

We could also re-target it to the master branch if the number of rebuilds are low enough.

I guess we could, but I think it's not urgent and we can just as well merge it into staging as well. So I'd keep it here.

@emilazy this should be good to go.

Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@emilazy emilazy merged commit c092fcf into NixOS:staging Nov 15, 2024
@wolfgangwalther wolfgangwalther deleted the no-python-eval-staging branch November 15, 2024 18:51
@aviallon
Copy link
Contributor

Has this been backported into 24.11 yet?

@wolfgangwalther
Copy link
Contributor Author

No, it hasn't and I don't think that's the plan.

@aviallon
Copy link
Contributor

Why? Packages are broken and need to be fixed anyway.

@wolfgangwalther
Copy link
Contributor Author

This PR was not about fixing any broken packages. It's more of a refactor to enable other changes in the future.

@aviallon
Copy link
Contributor

@wolfgangwalther I re-built from the PR, and the broken packages now build. More specifically, it fixes #354054.
So, in any case, I will at least backport the required fixes for certbot. Although it would probably be preferable to simply add a backport label to the PR (which doesn't break anything nor update anything, it just unbreaks a few builds).

@ShamrockLee
Copy link
Contributor

@aviallon My two cents: We could consider backporting changes that don't add additional working directory changes. As for other changes with additional pushd and popd, they should be backported only to fix something already broken.

@wolfgangwalther
Copy link
Contributor Author

I re-built from the PR, and the broken packages now build. More specifically, it fixes #354054.

I don't know how you come to that conclusion. My observations:

  • The certbot-dns- packages build fine on master right now.
  • This PR has not made its way to master, yet.
  • The packages fail to build on release-24.11.
  • When I backport the changes to those packages to 24.11 - they still fail to build.

Nothing indicates that any of the changes here fix the build for those packages anywhere.

@aviallon
Copy link
Contributor

@wolfgangwalther, I'm rebuilding from master right now. I may have built from a commit that is slightly too old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants