Skip to content
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

uv pip compile does not include extras in output #1595

Closed
palfrey opened this issue Feb 17, 2024 · 8 comments · Fixed by #2555
Closed

uv pip compile does not include extras in output #1595

palfrey opened this issue Feb 17, 2024 · 8 comments · Fixed by #2555
Assignees
Labels
needs-decision Undecided if this should be done

Comments

@palfrey
Copy link
Contributor

palfrey commented Feb 17, 2024

If for example you run echo "celery[redis]" | uv pip compile - then the redis extra is correctly picked up and the extra requirements added to the output. However, the output will contain something like celery==5.3.6, not celery[redis]==5.3.6 and pip-compile does the latter.

uv: 0.1.3

@charliermarsh
Copy link
Member

Are there benefits to including the extra? (Asking genuinely, I thought it was fine to omit since it shouldn’t affect installation given that everything is flattened.)

@palfrey
Copy link
Contributor Author

palfrey commented Feb 17, 2024

Debatable. So, in terms of "does this change what gets installed or the actual behaviour of packages", I don't think so. AFAIK packages don't have access to what extras they were installed only, and the only thing they see is "is package X in my extras installed".

In terms of "dev readability/trust", a little bit. If I told a package requirements system like pip-compile to compile a requirements file into a set of concrete requirements, and the extra bit goes away, I'm going to get a bit concerned.

There's an interesting pip-tools issue (jazzband/pip-tools#1613) talking about whether to remove this or not, and that flags a fun case with GDAL doing things depending on the order of installation (jazzband/pip-tools#1608 (comment))

@zanieb zanieb added the needs-decision Undecided if this should be done label Feb 17, 2024
@SnoopJ
Copy link

SnoopJ commented Feb 18, 2024

I personally use pip-compile as a way to record a canonical environment with a complete record of my intent. I guess you can argue that the original metadata is where the intent should live, but I find it helpful that pip-compile preserves the requirement, especially when comparing generated files without referring back to the originating metadata that contains the full story.

In lieu of filing a separate issue, I'll point out on this one that uv pip compile also drops environment makers like sys_platform and python_version, which is aggravating to my own workflow for the same reason: the generated file doesn't record my original intent, only the outcome of resolving my intent in the particular environment that ran the command. I'm not sure if that counts as a bug, actually, since installing files generated by pip-compile can vary across environments because of those markers, even if the expected workflow is that you generate your requirements file per-environment. Happy to file a separate issue if it's just noise on this one.


I'd say that if uv decides not to support this behavior of pip-compile (which will continue to exist, because --no-strip-extras allows you to explicitly opt out of the coming change in default behavior), the difference should be documented for unsuspecting users to whom it will matter (👋).

@zanieb zanieb changed the title uv pip compile removes extras from the output uv pip compile does not include extras in output Feb 18, 2024
@hauntsaninja
Copy link
Contributor

My 2c: This should certainly not be the default, pip-compile is doing the right thing by changing its default to --strip-extras. This ensures compatibility with constraints files, avoids pip bugs like pypa/pip#9644, etc

@palfrey
Copy link
Contributor Author

palfrey commented Feb 25, 2024

My 2c: This should certainly not be the default, pip-compile is doing the right thing by changing its default to --strip-extras. This ensures compatibility with constraints files, avoids pip bugs like pypa/pip#9644, etc

I'm not too fussed (especially given the possible change in pip-tools) about this being the default or not, provided there's an option to not strip them, which is my personal preference as I'd rather that and live with the possible issues from it. Also, it makes it much easier to use this as a drop-in "no changes in output" option from an existing pip-tools setup, and then maybe change the setting if I hit the issues later on.

@groodt
Copy link

groodt commented Mar 19, 2024

One datapoint from me:
rules_python (a set of bazel build rules for python), presently supports pip-tools compile lockfiles and it relies on the extras format for constructing the transitive dependency graph. It's possible we will eventually migrate to other other formats (or a standard lockfile if that ever materializes), but in the interim, we would be unable to support uv users (or even directly integrate with uv) without a flag to enable these extra annotations. From a rules_python maintainer POV, we don't mind if they're stripped by default, but it would help a lot of existing users if they could use --no-strip-extras to continue using their locking workflows with bazel, while swapping to uv instead of pip-tools for lockfile generation.

@charliermarsh
Copy link
Member

It's probably not too bad to add opt-in support for this. I will take a look.

@charliermarsh charliermarsh self-assigned this Mar 19, 2024
charliermarsh added a commit that referenced this issue Mar 19, 2024
## Summary

We strip extras by default, but there are some valid use-cases in which
they're required (see the linked issue). This PR doesn't change our
default, but it does add `--no-strip-extras`, which lets users preserve
extras in the output requirements.

Closes #1595.
@kennethreitz
Copy link

Thanks @charliermarsh I just used this functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Undecided if this should be done
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants