LinuxCommandLibrary

twine

Upload Python packages to PyPI

TLDR

Upload to PyPI

$ twine upload dist/*
copy

Upload to the Test PyPI repository to verify things look right
$ twine upload [[-r|--repository]] testpypi dist/*
copy

Upload to PyPI with a specified username and password
$ twine upload [[-u|--username]] [username] [[-p|--password]] [password] dist/*
copy

Upload to an alternative repository URL
$ twine upload --repository-url [repository_url] dist/*
copy

Check that your distribution's long description should render correctly on PyPI
$ twine check dist/*
copy

Upload using a specific pypirc configuration file
$ twine upload --config-file [configuration_file] dist/*
copy

Continue uploading files if one already exists (only valid when uploading to PyPI)
$ twine upload --skip-existing dist/*
copy

Upload to PyPI showing detailed information
$ twine upload --verbose dist/*
copy

SYNOPSIS

twine [OPTIONS] command [ARGS]

PARAMETERS

upload
    Upload distributions to a repository.

--repository-url
    The repository to use for the upload.

--username
    The username to use for authentication.

--password
    The password to use for authentication.

--cert
    Path to a custom certificate authority bundle.

--client-cert
    Path to a client certificate.

--config-file
    Path to the twine configuration file.

-v, --verbose
    Show verbose output.

-q, --quiet
    Suppress output except warnings and errors.

--version
    Show the version number and exit.

-h, --help
    Show this help message and exit.

DESCRIPTION

Twine is a command-line tool designed to securely publish Python packages to PyPI (Python Package Index) and other PyPI-compatible repositories. It simplifies the process of uploading distributions built with tools like setuptools and wheel.

By default, twine uses HTTPS to encrypt communication. This significantly enhances security compared to older methods. Twine supports verifying uploaded packages with cryptographic signatures for added confidence. It is the recommended tool for uploading packages to PyPI.

CAVEATS

Credentials provided via command-line options may be visible in shell history. It's recommended to use a configuration file or environment variables to store credentials.

CONFIGURATION FILE

Twine can be configured using a configuration file, typically located at ~/.pypirc. This file can store repository URLs, usernames, and passwords. This prevents these sensitive credentials from being stored directly on the command line.

HISTORY

Twine was created to address security vulnerabilities in older package uploading methods. It replaced the older 'python setup.py upload' command, which sent credentials in plaintext. Twine encrypts communication, making it much more secure to upload packages. It has become the standard tool for uploading Python packages to PyPI.

SEE ALSO

python(1)

Copied to clipboard