twine

twine is a Python command-line utility for uploading built packages and distribution archives to the Python Package Index (PyPI) and other package indexes that implement the same upload API.

Installation and Setup

Install it from PyPI into a virtual environment or system Python:

Shell
(venv) $ python -m pip install twine

Verify the installation:

Shell
(venv) $ twine --version

Key Features

  • Uploads distribution files securely over verified HTTPS/TLS.
  • Works with any build system that produces standard archives for sdists and wheels.
  • Supports uploading multiple files at once.
  • Validates distributions before upload with twine check to catch metadata or description rendering problems early.
  • Configures repositories and credentials via .pypirc, environment variables, and keyring integration.

Usage

After you build the distribution files, check them before upload:

Shell
$ twine check dist/*

Upload to TestPyPI:

Shell
$ twine upload --repository testpypi dist/*

Upload to PyPI once satisfied with the test upload:

Shell
$ twine upload dist/*

Tutorial

How to Publish an Open-Source Python Package to PyPI

In this step-by-step tutorial, you’ll learn how to create a Python package for your project and how to publish it to PyPI, the Python Package Repository. Quickly get up to speed on everything from naming your package to configuring it using setup.cfg.

intermediate best-practices tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Dec. 18, 2025