Publish and consume Python packages from the command line
TFS 2017
With Azure Artifacts, you can publish and consume packages from Azure Artifacts feeds as well as public registries such as pypi.org. Follow this quickstart to learn how to publish and consume Python packages using the command line.
Publish Python packages
To publish a Python package to your feed, follow these steps:
Install the latest version of Azure Artifacts keyring
pip install twine keyring artifacts-keyring
Add a .pypirc configuration file to your home directory
touch ~/.pypirc
Add the following content to your .pypirc file
[distutils] Index-servers = <organizationName> [<organizationName>] Repository = https://pkgs.dev.azure.com/<organizationName>/_packaging/<feedName>/pypi/upload
Create a source and a wheel distributions
python setup.py sdist bdist_wheel
Run the following command to publish your package
twine upload -r <organizationName> dist/*
Consume Python packages
To install a Python package from the command line, follow these steps:
Update your Python package installer
python -m pip install --upgrade pip
Ensure you have the latest version of Azure Artifacts keyring
pip install twine keyring artifacts-keyring
Create a virtual environment if you don't have one already
Add a pip.ini (Windows) or pip.conf (Mac/Linux) configuration file to your virtual environment
[global] extra-index-url=https://pkgs.dev.azure.com/<organizationName>/_packaging/<feedName>/pypi/simple/
Run the following command in your project directory to install your package
pip install <package>