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 will add and install packages that are not compatible with current python version #7869

Open
chris48s opened this issue Oct 2, 2024 · 6 comments
Labels
question Asking for clarification or support

Comments

@chris48s
Copy link

chris48s commented Oct 2, 2024

First off, apologies if this has already been reported. I did have a look over the tracker and could not find a similar issue. I am using uv==0.4.18. The problem I have hit is that uv will silently add and install packages that are not compatible with the project's python version without throwing an error.

So for example, if I have a project that uses python 3.12 I can uv add geojson==3.0.0 (this package isn't compatible with python 3.12) without error. I can run manually run uv pip check after installing and that will tell me that

The package `geojson` requires Python >=3.7, <=3.11, but `3.12.3` is installed

(or whatever) but in my opinion, trying to uv add, uv lock, uv sync etc should throw a hard error if I try to add/lock/sync packages that are not compatible with the project python version. The behaviour should be similar to the "No solution found when resolving dependencies" error seen when trying to install 2 incompatible packages.

To demonstrate the problem, I have a made a small repo at https://github.com/chris48s/uv-repro with a minimal UV/python 3.12 in it and a GitHub Actions Workflow that demonstrates the issue https://github.com/chris48s/uv-repro/blob/main/.github/workflows/build.yml
Here's a link to a build: https://github.com/chris48s/uv-repro/actions/runs/11146126874/job/30977334223

If you can't see the individual outputs of the workflow steps, you can fork or copy the repo, push it up and run it yourself to get a repro you can inspect. That said, it should hopefully be pretty easy to reproduce locally.

@Ravencentric
Copy link

This looks more like a uv pip check bug. https://pypi.org/project/geojson/#data explicitly declares 3.12 support via the trove classifier and defines the python requirement as >=3.7

@zanieb
Copy link
Member

zanieb commented Oct 2, 2024

This may be the same as #7462 (comment)

@Ravencentric
Copy link

In this case, geojson doesn't define an upper bound

@Ravencentric
Copy link

You're right! I was looking at the latest pypi release and the upper bound got removed there. But 3.0.0 still has it.

@zanieb zanieb added the question Asking for clarification or support label Oct 2, 2024
@chris48s
Copy link
Author

chris48s commented Oct 2, 2024

Yes. Note I picked explicitly geojson==3.0.0 here for this repro because I was looking for something which has an upper bound constraint. In this case <=3.11

I get that there are a lot of packages out there with a caret constraint on python-requires (e.g: ^3.7) that implies <4 (perhaps unintentionally) and it can be pragmatic to consider python >=3.7 and python >=3.7, <4 to be "the same", particularly when the project being managed is a package rather than an application.

A few thoughts:

  • Even if you're going to say ignoring <4 is pragmatic, a package that explicitly declares >=3.7, <=3.11 (for example) should perhaps be considered differently?
  • Ignoring upper-bound python constraints should be configurable IMO. Ideally you should opt in to ignoring it, but it should at least be possible to opt-out of this behaviour. Is there any option or configuration for this?
  • In the context where UV is managing an application with one target python version to install/deploy on rather than a package (which targets a range of python versions), not installing (or at least warning about) packages that have explicitly declared they are incompatible with that version seems particularly key.

That said, I'm familiar with the literature 📚

etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

3 participants