uv icon indicating copy to clipboard operation
uv copied to clipboard

Add pinning packages to private indexes with uv add --script

Open JonZeolla opened this issue 1 year ago • 2 comments

It would be nice to add support for pinning packages to indexes, including private indexes, in uv run --scripts. Today I do something like:

$ export UV_EXTRA_INDEX_URL https://aws:[email protected]/pypi/example/simple/
$ uv add --script ./example.py private_package
warning: Indexes specified via `--extra-index-url` will not be persisted to the script; use `--index` instead.
Updated `./example.py`
$ uv run --script ./example-py --index $UV_EXTRA_INDEX_URL

Which uses one index for everything. It would be nice to have something like index pinning in the metadata

JonZeolla avatar Nov 30 '24 21:11 JonZeolla

I think you want uv add --script ./example.py private_package --index aws=https://example.d.codeartifact.us-east-1.amazonaws.com/pypi/example/simple/? If you provide the index by name, it will be pinned.

You can then provide the credentials with UV_INDEX_AWS_USERNAME and UV_INDEX_AWS_PASSWORD. See: https://docs.astral.sh/uv/configuration/indexes/#providing-credentials.

charliermarsh avatar Dec 02 '24 01:12 charliermarsh

Hi, i got the same question and found a solution. @charliermarsh ’s answer is correct, but you have to set the UV_INDEX_AWS_USERNAME env variable to aws and the UV_INDEX_AWS_PASSWORD to your auth-token. Works for me and i hope this helps you as well!

Maybe this should be added to the docs? Took me a while to figure out :)

benedikt-hess-km avatar Dec 12 '24 12:12 benedikt-hess-km

Tracking docs in https://github.com/astral-sh/uv/issues/9867

zanieb avatar Jan 07 '25 19:01 zanieb