Publish and consume Python packages using the command line
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018
Azure Artifacts enables developers publishing and consuming packages from Azure Artifacts feeds and public registries like pypi.org. By following this quickstart guide, you can learn how to use the command line to publish and consume Python packages.
Publish Python packages
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts and then select your feed from the dropdown menu.
Select Connect to feed and then select twine from the left navigation panel.
If this is your first time using Azure Artifacts with twine, select Get the tools to install the prerequisites.
Download and install Python, and then run the following command to install the latest version of Azure Artifacts keyring.
pip install twine keyring artifacts-keyringAdd a .pypirc configuration file to your home directory.
touch ~/.pypircNote
If you already have a .pypirc file with credentials for the public PyPI index, it is recommended to remove the [pypi] section from your file to prevent unintended publication of private packages.
Paste the following snippet to your .pypirc file:
[distutils] Index-servers = <FEED_NAME> [<FEED_NAME>] Repository = https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/PROJECT_NAME/_packaging/<FEED_NAME>/pypi/upload/Create a source and wheel distributions.
python setup.py sdist bdist_wheelRun the following command to publish your package
twine upload -r <FEED_NAME> dist/*
Consume Python packages
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts and then select your feed from the dropdown menu.
Select Connect to feed and then select pip from the left navigation panel.
If this is your first time using Azure Artifacts with pip, select Get the tools to install the prerequisites.
Download and install Python, and then run the following command to update your Python package installer.
python -m pip install --upgrade pipInstall the latest Azure Artifacts keyring.
pip install twine keyring artifacts-keyringCreate a virtual environment if you don't have one already.
Add a pip.ini (Windows) or pip.conf (Mac/Linux) configuration file to your virtualenv.
[global] extra-index-url=https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/pypi/simple/Run the following command in your project directory to install your package.
pip install <PACKAGE_NAME>
Related articles
Feedback
Submit and view feedback for