-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Summary
My colleague (@sarmen-t) and I encountered that by following https://docs.astral.sh/uv/concepts/indexes/#providing-credentials-directly for injecting index credentials, uv pip compile $SRC_FILE
fails to use credentials if $SRC_FILE is not exactly pyproject.toml
(i.e., pyproject.toml cannot live in a subdirectory of CWD).
Here's a MWE (index url is faked)
[project]
name = "projectA"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ['internal-package']
[tool.uv.sources]
internal-package = { index = "internal-proxy" }
[[tool.uv.index]]
name = "internal-proxy"
url = "http://internal-proxy.example.com/simple/"
explicit = true
Contents of a multi-projects directory:
$ ls
projectA projectB README.md
$ ls projectA
src pyproject.toml
Fail case:
--no-cache
is added to force auth & downloading from remote index.
$ export UV_INDEX_INTERNAL_PROXY_USERNAME=public
$ export UV_INDEX_INTERNAL_PROXY_PASSWORD=koala
$ uv pip compile --format pylock.toml --no-cache projectA/pyproject.toml
error: Failed to fetch: `http://internal-proxy.example.com/packages/internal-package-3.3.1-py2.py3-none-any.whl`
Caused by: HTTP status client error (401 Unauthorized) for url (http://internal-proxy.example.com/packages/internal-package-3.3.1-py2.py3-none-any.whl)
Successful alternatives:
$ cd projectA
$ uv pip compile --format pylock.toml --no-cache pyproject.toml
$ uv pip compile --format pylock.toml --no-cache --project projectA/ projectA/pyproject.toml
We can see from the last successful alternative that the issue is due to --project
option which default to the CWD and is independent from $SRC_FILE
. The error makes sense, but it is surprising that uv pip compile
does not read the uv metadata table from the $SRC_FILE to obtain index metadata then subsequently its index credentials.
Platform
Darwin 24.6.0 x86_64
Version
uv 0.8.11 (Homebrew 2025-08-14)
Python version
Python 3.12.11