Get started with Python packages in Azure Artifacts
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018
This guide will walk you through using Azure Artifacts to publish and consume Python packages to and from your feed.
Create a feed
Select Artifacts, and then select Create Feed.
Give your feed a Name and choose its visibility (who can view packages in this feed), upstream sources, and scope (project-scoped or organization-scoped) settings.
Select Create when you're done.
Note
By default, the Project Collection Build Service (org-scoped) and the project-level Build Service (project-scoped) are set to Collaborator when you create a new feed.
Azure Artifacts comes pre-installed in TFS 2018. If this is the first time using your feed, you might be asked to assign a license
Go to Build & Release and select Packages.
Select + New feed.
Give your feed a Name, a Description, and set up who can read, who can contribute and if you want to Include external packages.
Select Create when you're done.
Connect to feed
There are two primary ways to connect to a feed to publish or consume your Python packages:
- Install and use the artifacts-keyring package, which will automatically set up authentication for you.
- Manually set up credentials for your .pypirc pushes, and your pip.ini/pip.conf for pulls with a personal access token (PAT).
Note
artifacts-keyring is not supported on newer versions of Ubuntu.
Use artifacts-keyring to set up authentication
The artifacts-keyring package allows you to set up authentication to publish and consume your Python packages to and from your feed. Both pip and twine use the Python keyring library to find credentials.
Important
You must have pip 19.2 and twine 1.13.0 or higher to use artifacts-keyring. See Usage requirements for more details.
In an elevated command prompt window, run the following command to install the artifacts-keyring package:
pip install artifacts-keyring
To install a package from your feed, run the following command:
Project scoped feed:
pip install <PACKAGE_NAME> --index-url https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/pypi/simple
Organization scoped feed:
pip install <PACKAGE_NAME> --index-url https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/pypi/simple
To publish a package to your feed, run the following command:
Project scoped feed:
twine upload --repository-url https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/pypi/upload
Organization scoped feed:
twine upload --repository-url https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/pypi/upload
Note
The artifacts-keyring package is layered on top of the Azure Artifacts Credential Provider. For more advanced configuration options, check out the artifacts-credprovider repository.
Manually configure authentication
Create a Personal access token with Packaging > Read scope to authenticate with Azure DevOps.
Select Artifacts, and then select your feed then select Connect to feed.
Select pip under the Python section.
If this is your first time using Azure Artifacts with twine, select Get the tools to download and install the prerequisites.
Create a virtualenv, if you don't already have one.
Add a pip.ini (Windows) or a pip.conf (Mac/Linux) file to your virtualenv. Make sure you don't check your personal access token into a public repository.
Project scoped feed:
[global] extra-index-url=https://<FEED_NAME>:<YOUR_PERSONAL_ACCESS_TOKEN>@pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/pypi/simple/
Organization scoped feed:
[global] extra-index-url=https://<FEED_NAME>:<YOUR_PERSONAL_ACCESS_TOKEN>@pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/pypi/simple/
Run the following command in your project directory to install your package.
pip install <PACKAGE_NAME>
When you connect to Azure DevOps for the first time, you'll be prompted for credentials. Enter your user name(any string) and your personal access token in the appropriate fields. The credentials will be cached locally and used to automatically sign you in the next time you use the service.
Note
If you want to publish or consume your packages using Azure Pipelines, use the Python Pip Authenticate task to authenticate and install packages, or the Python Twine Upload Authenticate task to publish your packages.
Related articles
Feedback
Submit and view feedback for