-
Notifications
You must be signed in to change notification settings - Fork 1.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
Incorrect precedence of UV_INDEX_URL vs --index-url in reqs file #6407
Comments
Hmm, I think it's arguably unclear what we should use here. I would find it more dangerous that the environment variable (which is presumedly set by the user) is ignored, and the one in a |
Below, I'm intending to convince you that retaining compatibility with pip is a better choice than documenting as an incompatibility. Consider when there is a custom default index set. This is pretty common in corporate environments, where PyPI packages may need to be cached, whitelisted or shadowed with patched versions, e.g. by using an internal devpi-server. The custom index is set as the default index (for all users) by The next-best option for the sysadmin to put a sensible default index for uv would probably be setting However, if the As I mentioned earlier, the simple failure mode is that packages are not found, but the more confusing and hard-to-debug failure mode is if the installation succeeds but uses the wrong packages (because it was using the wrong index). Switching from The failure mode I describe might sound like a weird edge-case, but could actually be quite common especially with devpi-server, where "team-specific" indices could inherit and mirror a default index, to host a mix of their own/patched local versions layered over the default versions.
I'm not sure what you mean here? Unless I'm mistaken, it is part of the requirements file format that the file can control the index-url. This is not dangerous, because requirements files and their custom indices can not be used during dependency resolving from some other top-level installation candidate. The requirements file would have been installed directly with |
I'm currently faced with this problem. I would love to specify index rules in the pyproject.toml file and completely ignore --index and --extra-index definitions in We use uv like this:
All external Ansible collections are ina I have two internal projects that should be looked up ONLY internally (in two different indexes) and the rest on pypi. |
If an index url has been specified directly in the requirements file using
-i
or--index-url
, this should have precedence over env var.Currently uv will use UV_INDEX_URL if it's set, and ignore the one in the requirements file. Reproducer:
This is in contrast to pip, where the index url from environment is lower priority to the cmd:
This makes
uv
+ UV_INDEX_URL somewhat dangerous to use as a drop-in replacement forpip
+ PIP_INDEX_URL. A failure to install is not the worst scenario, the worst is that you succeed to install potentially totally different packages from a totally different index (note: checksums in the reqs file could protect you from that).The text was updated successfully, but these errors were encountered: