Publish Python packages with Azure Pipelines
Azure DevOps Services
Using Azure Pipelines, you can publish your Python packages to Azure Artifacts feeds, public registries, or as a pipeline artifacts.
This article will show you how to:
- Install
Twine
- Authenticate with your Azure Artifacts feeds
- Publish Python packages to an Azure Artifacts feed
Install twine
Authenticate with Azure Artifacts
To use twine
to publish your Python packages, you must first set up authentication to you Azure Artifacts feed. The TwineAuthenticate task stores your credentials in a PYPIRC_PATH
environment variable. twine
will reference this variable to publish your packages from your pipeline.
- task: TwineAuthenticate@1
inputs:
artifactFeed: <PROJECT_NAME/FEED_NAME> #For an organization-scoped feed, artifactFeed: <FEED_NAME>
pythonUploadServiceConnection: <NAME_OF_YOUR_SERVICE_CONNECTION>
- artifactFeed: The name of your feed.
- pythonUploadServiceConnection: a service connection to authenticate with twine.
Tip
The credentials stored in the PYPIRC_PATH
environment variable supersede those in your .ini
and .conf
files.
If you add multiple TwineAuthenticate tasks at different stages in your pipeline, each additional task execution will extend (not override) the existing PYPIRC_PATH
environment variable.
Publish Python packages to Azure Artifacts feeds
- script: |
pip install wheel
pip install twine
- script: |
python setup.py bdist_wheel
- task: TwineAuthenticate@1
displayName: Twine Authenticate
inputs:
artifactFeed: <PROJECT_NAME/FEED_NAME> #For an organization-scoped feed, artifactFeed: <FEED_NAME>.
- script: |
python -m twine upload -r feedName --config-file $(PYPIRC_PATH) dist/*.whl
Related articles
Feedback
Submit and view feedback for