-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
python3.pkgs.buildPythonPackage: Separate runtime & build time dependencies #271597
python3.pkgs.buildPythonPackage: Separate runtime & build time dependencies #271597
Conversation
b63f4d3
to
65f1f51
Compare
b3515e8
to
c330367
Compare
I wonder if it would be better to just expose a new mkDerivation helper (e.g. |
As discussed on Matrix I don't like adding another function because:
|
💯 Also if we can get away with not fragmenting things and just shove this under the current system without breaking everything then I would be super happy. |
The main topic here is the separation. We need that, without a doubt. Then there is the naming. This PR introduces non-standard names for Nixpkgs, but names that are the standard in Python packaging. While I've long held the opinion that we should have names that are similar to what is used elsewhere in Nixpkgs, this builder is used by other higher-level tools such as dream2nix and pdm2nix, which would preferably work with an interface more closely aligned to Python packaging, and for direct users of this function it is I think also more convenient. I'd say let's go ahead with this. |
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 have no particular opinion on the naming and have left some comments about the document.
Then, not just for this PR, but I would like to see a section like the changelog.
Since not everyone follows these discussions and changes, it would be easier to catch up if we had something to list all the changes.
f97727e
to
62fafde
Compare
Rebased, refactored & fixed comments. |
68e2446
to
cbc7eac
Compare
Since NixOS#161835 we've had the concept of `passthru.optional-dependencies` for Python optional deps. Having to explicitly put optional-dependencies in the passthru attrset is a bit strange API-wise, even though it semantically makes sense. This change unifies the handling of non-optional & optional Python dependencies using the names established from PEP-621 (standardized pyproject.toml project metadata).
Much like the previous commit that adds dependencies & optional-dependencies this aligns PEP-517 build systems with how they are defined in PEP-518/PEP-621. The naming `build-system` (singular) is aligned with upstream Python standards.
cbc7eac
to
07a221b
Compare
NixOS/nixpkgs#271597 implemented a new format for python packages that is starting to get traction in nixpkgs/unstable (soon to become NixOS 24.05). That is a progress towards NixOS/nixpkgs#272178, which would be a massive improvement for dream2nix once completed. This first step just makes sure that `buildPythonPackage` supports the new arguments properly. Without this change, many dream2nix python derivations fail to build on nixos-unstable right now. Probably other python auto-builders should leverage these new options when available for the d2n user. That can be added later. @moduon MT-1075
NixOS/nixpkgs#271597 implemented a new format for python packages that is starting to get traction in nixpkgs/unstable (soon to become NixOS 24.05). That is a progress towards NixOS/nixpkgs#272178, which would be a massive improvement for dream2nix once completed. This first step just makes sure that `buildPythonPackage` supports the new arguments properly. Without this change, many dream2nix python derivations fail to build on nixos-unstable right now. Probably other python auto-builders should leverage these new options when available for the d2n user. That can be added later. @moduon MT-1075
NixOS/nixpkgs#271597 implemented a new format for python packages that is starting to get traction in nixpkgs/unstable (soon to become NixOS 24.05). That is a progress towards NixOS/nixpkgs#272178, which would be a massive improvement for dream2nix once completed. This first step just makes sure that `buildPythonPackage` supports the new arguments properly. Without this change, many dream2nix python derivations fail to build on nixos-unstable right now. Probably other python auto-builders should leverage these new options when available for the d2n user. That can be added later. @moduon MT-1075
NixOS/nixpkgs#271597 implemented a new format for python packages that is starting to get traction in nixpkgs/unstable (soon to become NixOS 24.05). That is a progress towards NixOS/nixpkgs#272178, which would be a massive improvement for dream2nix once completed. This first step just makes sure that `buildPythonPackage` supports the new arguments properly. Without this change, many dream2nix python derivations fail to build on nixos-unstable right now. Probably other python auto-builders should leverage these new options when available for the d2n user. That can be added later. @moduon MT-1075
on the Nix side, i feel like we've spent a good deal of effort pushing language-specific logic away from nativeBuildInputs = [ poetry-core ]; to build-system = [ poetry-core ]; isn't this a regression? as far as i can tell, |
No, a conscious decision to adopt the PEP518/621 lingo in the Python-specific builders. |
it's not clear to me reading just this PR thread if there is wide agreement in adopting python-specific lingo at this level within nixpkgs. at least, in the handful of people who weighed in here, the issue of naming/jargon was mentioned more than once. honestly, i don't mean to bikeshed, and if this was discussed more thoroughly in a different thread then link me there and i'll be quiet. yet i think it has to be acknowledged that this has real repercussions (some bad, some good) for first-time packagers. new contributors have a hard enough time writing their first package. it's made worse if none of the knowledge learned in that first package carries through to their second package. |
Yes, this change would significantly benefit nixpkgs. Adding Python modules to the We did not change You will also encounter these concepts when using I've packaged and maintained hundreds of packages, but I still can't work in an unfamiliar category without reading the manual (or the source code) though. |
Incorporates: - NixOS/nixpkgs#271597 - NixOS/nixpkgs#253154 Closes #130
Incorporates: - NixOS/nixpkgs#271597 - NixOS/nixpkgs#253154 Closes #130
|
||
Aside from propagating dependencies, | ||
`buildPythonPackage` also injects code into and wraps executables with the | ||
paths included in this list. Items listed in `extras_requires` go 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.
That's a duplicate.
Aside from propagating dependencies, | |
`buildPythonPackage` also injects code into and wraps executables with the | |
paths included in this list. Items listed in `extras_requires` go 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.
fix is out for review here: #322267
NixOS/nixpkgs#271597 implemented a new format for python packages that is starting to get traction in nixpkgs/unstable (soon to become NixOS 24.05). That is a progress towards NixOS/nixpkgs#272178, which would be a massive improvement for dream2nix once completed. This first step just makes sure that `buildPythonPackage` supports the new arguments properly. Without this change, many dream2nix python derivations fail to build on nixos-unstable right now. Probably other python auto-builders should leverage these new options when available for the d2n user. That can be added later. @moduon MT-1075
Description of changes
See #272178 for more context.
Dependency separation
Adds a separation between Python runtime dependencies, Python build-time dependencies & non-Python dependencies arguments to
buildPythonPackage
.It's important to have these distinctions so we can solve our long standing issues re dependency propagation in Python.
With this change in place it's possible to implement a solution for #170577.
It's similar to #102613 (a subset, really) but with the notable changes that:
WIP: Python: wrap and patch using
requiredPythonModules
instead ofpropagatedBuildInputs
#102613 introduces the argumentrequiredPythonModules
, but with Python metadata being standardised I'd like to be more closely aligned with that.It's probably going to take a while to refactor all of nixpkgs to use the appropriate arguments.
This change is purposely minimal in the hopes that we can move forward with it more quickly.
For now
dependencies
are always mapped ontopropgatedBuildInputs
, so there is no change in behaviour in the immediate term.2 packages are migrated as a PoC, one is using
format = "pyproject"
and the other issetuptools
.Interface changes
This also unifies regular dependencies with optional dependencies:
becomes
which looks much more like what a standard
pyproject.toml
file contains.I think the interface change alone is a pretty good improvement.
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/
)Priorities
Add a 👍 reaction to pull requests you find important.