Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 3.42 KB

python-cli.md

File metadata and controls

71 lines (46 loc) · 3.42 KB
title description ms.service ms.topic ms.custom ms.date monikerRange recommendations
Publish Python packages (CLI)
Learn how to publish Python packages from the command-line interface.
azure-devops-artifacts
how-to
engagement-fy23, devx-track-python
01/15/2025
<=azure-devops
true

Publish Python packages (CLI)

[!INCLUDE version-gt-eq-azure-devops-2019]

This article guides you through publishing Python packages to an Azure Artifacts feed using the NuGet command-line interface.

Prerequisites

Product Requirements
Azure DevOps - An Azure DevOps organization.
- An Azure DevOps project.
- Download and install Python.

Create a feed

[!INCLUDE ]

Publish packages

  1. Follow the steps in the Project setup to authenticated with your feed if you haven't done so, then proceed to the next step.

  2. Sign in to your Azure DevOps organization, and then navigate to your project.

  3. Select Artifacts, and then select Connect to feed.

  4. Select twine from the left navigation area. If this is your first time using Azure Artifacts with twine, make sure to install the prerequisites by selecting Get the tools and following the provided steps.

  5. Add a pypirc file to your home directory and paste the provided snippet into it. Your file should look similar to the following snippet. If you already have a pypirc that contains credentials for the public PyPI index, we recommend removing the [pypi] section to avoid accidentally publishing private packages to PyPI.

    [distutils]
    Index-servers =
    FEED_NAME
    
    [FEED_NAME]
    Repository = https://pkgs.dev.azure.com/ORGANIZATION_NAME/PROJECT_NAME/_packaging/FEED_NAME/pypi/upload/
    
  6. Run the following command in your project directory to create source and wheel distributions.

    python setup.py sdist bdist_wheel
    
  7. Run the following command to publish your package. Use the -r REPOSITORY_NAME flag to ensure that your private packages are not accidentally published to PyPI.

    twine upload -r REPOSITORY_NAME dist/*
    

Important

You must have twine 1.13.0 or higher to use artifacts-keyring. See Usage requirements for more details.

Related content