uv: Private package not found from Azure DevOps

I tested the latest fix (https://github.com/astral-sh/uv/issues/3291) and still can’t install a private package using uv due to another error.

requirements.txt

sqlmodel==0.0.14
my-private-package==1.0.0

Execution:

$ uv --version
uv 0.1.42
$ uv pip install --system keyring artifacts-keyring

$ az login

$ uv pip install --system --extra-index-url=https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple --keyring-provider subprocess --requirement requirements.txt --verbose

DEBUG Starting interpreter discovery for default Python
DEBUG Cached interpreter info for Python 3.12.3, skipping probing: /usr/local/bin/python3
DEBUG Using Python 3.12.3 environment at /usr/local/bin/python3
DEBUG Trying to lock if free: /tmp/uv-39ee7c309557c5e9.lock
DEBUG At least one requirement is not satisfied: my-private-package==1.0.0
DEBUG Using registry request timeout of 30s
DEBUG Solving with target Python version 3.12.3
DEBUG Adding direct dependency: sqlmodel==0.0.14
DEBUG Adding direct dependency: my-private-package==1.0.0
DEBUG No cache entry for: https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/my-private-package/
DEBUG No cache entry for: https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/sqlmodel/
DEBUG No cache entry for: https://pypi.org/simple/my-private-package/
DEBUG Found stale response for: https://pypi.org/simple/sqlmodel/
DEBUG Sending revalidation request for: https://pypi.org/simple/sqlmodel/
DEBUG Found not-modified response for: https://pypi.org/simple/sqlmodel/
DEBUG Searching for a compatible version of sqlmodel (==0.0.14)
DEBUG Selecting: sqlmodel==0.0.14 (sqlmodel-0.0.14-py3-none-any.whl)
DEBUG Found fresh response for: https://files.pythonhosted.org/packages/55/b2/ea0c31d2bb8d22dffd83f43028d8d1b18301702725d6b918ac15f99b6de7/sqlmodel-0.0.14-py3-none-any.whl.metadata
DEBUG Adding transitive dependency for sqlmodel==0.0.14: sqlalchemy>=2.0.0, <2.1.0
DEBUG Adding transitive dependency for sqlmodel==0.0.14: pydantic>=1.10.13, <3.0.0
DEBUG No cache entry for: https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/sqlalchemy/
DEBUG No cache entry for: https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/pydantic/
DEBUG Found stale response for: https://pypi.org/simple/pydantic/
DEBUG Sending revalidation request for: https://pypi.org/simple/pydantic/
DEBUG Searching for a compatible version of my-private-package (==1.0.0)
DEBUG No compatible version found for: my-private-package
  × No solution found when resolving dependencies:
  ╰─▶ Because my-private-package was not found in the package registry and you require my-private-package==1.0.0, we
      can conclude that the requirements are unsatisfiable.

If I use pip, I can:

$ pip install --root-user-action=ignore --extra-index-url=https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple --requirement requirements.txt

Looking in indexes: https://pypi.org/simple, https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple
[Warning] [CredentialProvider]Warning: Cannot persist Microsoft authentication token cache securely!
[Warning] [CredentialProvider]Warning: Using plain-text fallback token cache
[Minimal] [CredentialProvider]DeviceFlow: https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/
[Minimal] [CredentialProvider]ATTENTION: User interaction required.

    **********************************************************************

    To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ... to authenticate.

    **********************************************************************
[Information] [CredentialProvider]VstsCredentialProvider - Acquired bearer token using 'MSAL Device Code'
[Information] [CredentialProvider]VstsCredentialProvider - Attempting to exchange the bearer token for an Azure DevOps session token.
...

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 37 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Being able to install private packages from Azure DevOps is essential in my company to use uv. Could you please tell us if you’re going to invest resources to solve it in the near time?

Thank you 😃

Maybe like they implemented that wrong? cc @BakerNet You can use python -c 'import keyring; keyring.get_credential("<url>", username=None)' instead

Looks like a typo in keyring @jaraco

AttributeError: 'CommandLineTool' object has no attribute '_get_creds'. Did you mean: '_get_cred'?

Fixed in v25.2.1. Probably need to get better coverage on that CLI module.

@fralik you should be able to add

[tool.uv]
keyring-provider = "subprocess"
index-url = "https://VssSessionToken@pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/"

to your pyproject.toml or to a uv.toml file (without the [tool.uv] section)

It works for me… Are you getting your credentials first before installing packages with uv? keyring --mode creds get https://pkgs.dev.azure.com/orgname/_packaging/Packages/pypi/simple/

Can this issue be closed now that the documentation is merged into main? Has anyone had difficulty connecting to Artifacts using the guide?

@fralik you should be able to add

[tool.uv]
keyring-provider = "subprocess"
index-url = "https://VssSessionToken@pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/"

to your pyproject.toml or to a uv.toml file (without the [tool.uv] section)

Thanks, Zanie. As a note, you can skip keyring and just install artifacts-keyring.

This is our pyproject. We use PyPi and private packages.

[tool.uv.pip]
keyring-provider = "subprocess"
extra-index-url = [
    "https://VssSessionToken@pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/",
]

With that configuration, in the CI/CD you have to override these environment variables:

UV_KEYRING_PROVIDER="disabled"
UV_EXTRA_INDEX_URL="https://$ARTIFACT_FEED_ACCESS_TOKEN@pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/"

Not sure if related, but there was an issue with artifacts-keyring that was fixed 1-2 weeks ago. It was sometimes printing stuff other than the credentials to stdout. https://github.com/microsoft/artifacts-keyring/pulls

I’ve rebuilt the DevContainer (I’m using python:3.12-bookworm) and I forced the latest versions, but I got the same result:

$ pip install --root-user-action=ignore uv==0.2.21

$ uv pip install --system keyring==25.2.1 artifacts-keyring==0.3.6

$ keyring --mode creds get https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/

$ uv pip install --extra-index-url=https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/ --keyring-provider subprocess my-private-package==1.0.0

  × No solution found when resolving dependencies:
  ╰─▶ Because my-private-package was not found in the package registry and you require my-private-package==1.0.0, we can conclude that the requirements are unsatisfiable.

After this, if I don’t use uv:

$ pip install --extra-index-url=https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/ --keyring-provider subprocess my-private-package==1.0.0

This requires me the username and password:

User for pkgs.dev.azure.com:

Try this for your extra index URL: pip install --extra-index-url=https://VssSessionToken@pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/

Humm, and the keyring command works fine? You are able to sign-in and if you do it again it prints the username-token combo?

Yes. It prints VssSessionToken and the token.

I’d love for this to be fixed too, but it’s not entirely clear what we need to change.

Perhaps we need to be requesting https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple specifically? I believe this was discussed some at https://github.com/astral-sh/uv/issues/4056

Every keyring plugin works differently and it is difficult to give them all what they want. Some clarity on the exact requirements of the Azure plugin would help move this issue forward.

Sorry about the trouble and thanks for the additional debugging info. It looks like the keyring did not respond with credentials:

DEBUG Checking keyring for credentials for VssSessionToken@https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/sqlmodel/
TRACE Checking keyring for URL https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/sqlmodel/
TRACE Checking keyring for host pkgs.dev.azure.com

Perhaps their plugin only works with the username omitted / via the get_creds API that we do not support?

Maybe like they implemented that wrong? cc @BakerNet

You can use python -c 'import keyring; keyring.get_credential("<url>", username=None)' instead

Looks like a typo in keyring @jaraco

AttributeError: 'CommandLineTool' object has no attribute '_get_creds'. Did you mean: '_get_cred'?

Thanks!

So this difference here is that pip is able to use keyring’s Python API which allows retrieval of both a username and password. We can’t use that, we’re limited to the CLI API which only allows retrieval of a password for a given username. Since your URL does not include a username, we skip the keyring lookup:

Skipping keyring lookup for https://pkgs.dev.azure.com/mycompany/_packaging/MyFeed/pypi/simple/my-private-package/ with no username

If you add a username to your index URL, we’ll look up the credentials as you’d expect.