Get started with Python packages in Azure Artifacts
Azure DevOps Services | Azure DevOps Server 2019 Update 1
This quickstart guides you through using Azure Artifacts to consume and publish Python packages by creating and connecting to a feed.
Create a feed
In the left navigation of your Azure DevOps project, select Artifacts.
On the Artifacts page, select Create Feed.
In the Create new feed dialog box:
In the Name field, give the feed a name.
PyPI is the default repository name for
twine, which is a tool for publishing Python packages. It's best not to name your feed PyPI, because if you don't use
-rto specify a repository name when pushing, you might accidentally push to the wrong repository.
Under Visibility, select who can read and contribute, or update, packages in your feed. The recommended People in <your organization> setting lets all members in the organization see and use your feed.
Under Packages from public sources, select Use packages from public sources through this feed to add the public
PyPIregistries as upstreams to your feed.
When these upstreams are enabled, your client will be able to fetch packages from the public registry through your private feed, and your private feed will cache those packages for you. If you select Only use packages published to this feed, your feed won't be connected to public registries, but you can connect to them later if you want.
To edit your feed settings, select the gear icon at upper right on the feed page, and then select Feed settings.
Connect to your feed
There are two primary ways to connect to a feed to push or pull Python packages:
- Install and use the Python Credential Provider (artifacts-keyring) (preview), which sets up authentication for you.
- Manually set up credentials for
pip.conffor pushes, or
.pypircfor pulls, through a personal access token (PAT).
Option 1: Use Python Credential Provider (preview) to automate authentication
The Python Credential Provider is an
artifacts-keyring package in public preview that you can install from the Python Package Index (PyPI). The Python Credential Provider lets the pip and twine commands authenticate by sending you through an authentication flow in your web browser.
The Python Credential Provider is a manual interaction. If you want to set up authentication in an Azure Pipelines pipeline, use the Pip Authenticate task to install packages, or the Twine Upload Authenticate task to push packages.
You must have
pip version 19.2 and
twine version 1.13.0 or higher installed to use the Python Credential Provider.
From your command line, install the artifacts-keyring package:
pip install artifacts-keyring --pre
Install or upload packages to your feed.
pipinstalls, run the following command:
pip install <package-name> --index-url https://pkgs.dev.azure.com/<your organization name>/_packaging/<your feed name>/pypi/simple
twineuploads, run the following command:
twine upload --repository-url https://pkgs.dev.azure.com/<your organization name>/_packaging/<your feed name>/pypi/upload <package wheel or other dist format>
Follow the authentication flow in your browser.
Option 2: Manually configure authentication
From your feed in Azure Artifacts, select Connect to feed.
In the Connect to feed dialog box, select Python from the left menu.
Follow the instructions to Get packages with pip or Upload packages with twine.
To consume or publish Python packages as part of your continuous integration/continuous delivery (CI/CD) pipeline, see Publish Python packages in Azure Pipelines.
To learn more about how to create, configure, and use Python packages as part of your project or pipeline, see Build Python apps.
If you’d like to learn more about how Python packages work, see The Architecture of Open Source Applications: Python Packaging, an excerpt from the book Architecture of Open Source Applications.