astral-sh/uv

Clearer output on index strategy, determined source index and indexes being queried for uv pip install <package>

Open

#4,389 opened on Jun 18, 2024

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (3,111 forks)batch import
error messageshelp wanted

Repository metrics

Stars
 (84,934 stars)
PR merge metrics
 (Avg merge 7d 16h) (259 merged PRs in 30d)

Description

Platform

➜ uname -a    
Darwin FA-3620-MBPRO14 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
➜ uv --version
uv 0.2.11 (44041bccd 2024-06-11)

Issue

When running uv pip install for a given package (or multiple via -r requirements.txt in my case) it would be useful as an end-user for the determined source index for the given package to also be output as well as the indexes being queried.

➜ cat ~/.config/uv/uv.toml  
[pip]
extra-index-url = ["https://private.index1/simple", "https://private.index2/simple", "https://pypi.python.org/simple"]

Initally my index list looked like this ^.

➜ uv pip install python-geohash
  × No solution found when resolving dependencies:
  ╰─▶ Because only python-geohash==0.8.5 is available and python-geohash==0.8.5 has no wheels are available with a
      matching Python ABI, we can conclude that all versions of python-geohash cannot be used.
      And because you require python-geohash, we can conclude that the requirements are unsatisfiable.

No compatible package found since this would just be querying https://private.index1/simple but this wasn't obvious to me based on the output. Having this determined source index for this package output inline would have been helpful here, since I was uninformed of changes to index priority/behaviour in uv vs. pip.

➜ uv pip install python-geohash --index-strategy unsafe-best-match
Resolved 1 package in 794ms
Installed 1 package in 4ms
 + python-geohash==0.8.5

To replicate something close to pip's behaviour I used --index-strategy unsafe-best-match. Having the determined source index as well as the indexes that are being queried (for both unsafe index-strategies) would be useful here also. Similar to how pip install <package> will output:

Looking in indexes: https://private.index1/simple, https://private.index2/simple, https://pypi.python.org/simple
Collecting <package>
  Downloading <index>/<package>

There was increased confusion around this issue due to being uninformed of the changes within uv vs. pip regarding priority of indexes and default index strategy. I had expected all indexes to be queried similar to pip's default behaviour but the output above lead me to believe I was experiencing an access/auth/compatibility resolution problem. IMO this would be a sensible addition to make these uv-specific changes clearer to end-users as well as reduce troubleshooting required for instances where package sources could be modified (e.g. overlapping config files, env vars added in pipeline processes etc.).

Contributor guide