
## Summary As discussed in #3542 - there has been some confusion about how to get `uv` to work with ADO Artifacts so I'm adding a quick guide. ## Test Plan Smoke-tested the examples on my machine.
2.6 KiB
Using Azure Artifacts
uv
can install packages from Azure DevOps Artifacts. You can authenticate to a feed using a Personal Access Token or interactively using Keyring.
Authenticate using a PAT
If you have a Personal Access Token available (eg $(System.AccessToken)
in an Azure pipeline), you can authenticate to Artifacts using Basic Auth. Simply include the PAT in the password field of the URL. The username can be any dummy string.
# if your token is in the ADO_PAT environment variable
export UV_EXTRA_INDEX_URL=https://dummy:$ADO_PAT@pkgs.dev.azure.com/{organisation}/{project}/_packaging/{feedName}/pypi/simple/
uv pip install my-private-package
Authenticate using Keyring
If you don’t have a PAT handy, you can authenticate to Artifacts using keyring
with the artifacts-keyring
plugin. Because you’ll be using these two packages to authenticate to Azure Artifacts, you should arrange to have them installed into your environment from a source other than Artifacts.
The artifacts-keyring
plugin wraps the Azure Artifacts Credential Provider tool. The credential provider supports a few different authentication modes including interactive login — see the tool's docs for information on how to configure it.
uv
only supports using Keyring in subprocess mode. The keyring
executable must be on the PATH
, meaning it should be installed globally or into your currently-active virtual environment. Keyring’s CLI requires a username in the URL, so you should modify your index URL to include the default username VssSessionToken
.
# preinstall keyring and the Artifacts plugin from the public PyPI
uv pip install keyring artifacts-keyring
# enable uv's keyring integration
export UV_KEYRING_PROVIDER=subprocess
# include default username in URL
export UV_EXTRA_INDEX_URL=https://VssSessionToken@pkgs.dev.azure.com/{organisation}/{project}/_packaging/{feedName}/pypi/simple/
uv pip install my-private-package