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

Private repository as a source #6421

Closed
NevoleMarek opened this issue Aug 22, 2024 · 12 comments
Closed

Private repository as a source #6421

NevoleMarek opened this issue Aug 22, 2024 · 12 comments
Labels
configuration Settings and such question Asking for clarification or support

Comments

@NevoleMarek
Copy link

Hi, I d'like to transition from poetry to uv. What I am missing is a way of using private repositories as source for packages.

Poetry allows to add private repositories like so:

poetry source add --priority=supplemental foo https://pypi.example.org/simple/

and then to install package from the repository like so:

poetry add --source foo private-package

Can this be sensibly done using uv?

I guess it could somehow be done via HTTP URLs but that seems a bit cumbersome.

@charliermarsh
Copy link
Member

charliermarsh commented Aug 22, 2024

So, today, you would do something like this in your pyproject.toml:

[tool.uv]
extra-index-url = ["https://pypi.example.org/simple/"]

uv will then look in https://pypi.example.org/simple/ before looking in PyPI, and if a package exists on that index, it won't check PyPI at all.

We'll likely add a more granular index API in the future that looks more like what you get in Poetry, PDM, or Rye.

@charliermarsh
Copy link
Member

If you want to replace PyPI entirely, you can do:

[tool.uv]
index-url = "https://pypi.example.org/simple/"

@charliermarsh
Copy link
Member

Alternatively, you can define these globally in ~/.config/uv/uv.toml:

extra-index-url = ["https://pypi.example.org/simple/"]

@charliermarsh charliermarsh added the configuration Settings and such label Aug 22, 2024
@NevoleMarek
Copy link
Author

Thanks for the response

I guess the setting extra-index-url with index-strategy = "first-index" will do for now.

Looking forward to more granular API in the future.

One thing I would like to prevent via the future API is dependency confusion attacks.

@charliermarsh
Copy link
Member

Makes sense. Our default strategy is more resilient to such attacks than pip (since, if a package exists on your index, we won't even look at PyPI, even if a more recent version is available there), but we do want to add an API that allows for explicit package-to-index assignments.

@rafalkrupinski
Copy link

Regarding private source repository, is there a way to provide credentials?

@NevoleMarek
Copy link
Author

The simplest way would be to add the private source repo as extra-index-url already with the credentials as follows:

[tool.uv]
extra-index-url = ["https://<username>:<password>@<index_url>"]

But as you can imagine this not the safest option. A bit more cumbersome but viable option is to specify the index and credentials with the uv add command and environment variables.

uv add package --extra-index-url https://${USERNAME}:${PASSWORD}@<index_url>

What I would like to see in the future is something similar to Poetry's way of doing this.

In addition to simple addition of sources they also provide the following way to add credentials to the sources.

poetry config http-basic.your_index <username> <password> find more here

There are other options that uv recommends for http authentication but they are not the simplest either or maybe I am missing something

@rafalkrupinski
Copy link

@NevoleMarek thanks, I'll check it out!

@zanieb zanieb added the question Asking for clarification or support label Aug 26, 2024
@rafalkrupinski
Copy link

Actually I like the idea of using keyring and KWallet integration. Way better than storing passwords in open text.

@yohann84L
Copy link

Still no alternative to the poetry config http-basic.your_index <username> <password> ?

@zanieb
Copy link
Member

zanieb commented Oct 21, 2024

We support UV_INDEX_<NAME>_USERNAME and UV_INDEX_<NAME>_PASSWORD now in addition to indexes in source definitions.

@zanieb zanieb closed this as completed Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

5 participants