uv-publish
Publish Python packages
TLDR
Publish packages from dist/ directory (default behavior)
Publish to a specific repository URL
Publish using a specific username and password
Publish using an API token
Publish specific distribution files
Publish to TestPyPI for testing
SYNOPSIS
uv publish [OPTIONS] [PATH]
PARAMETERS
PATH
Path to the source distribution (sdist), wheel distribution (wheel), or a directory containing a pyproject.toml or setup.py file. Defaults to the current directory.
-r, --repository
The repository URL or name (e.g., 'pypi', 'testpypi') to publish to. Can be set via the UV_REPOSITORY environment variable.
-u, --username
The username for authentication. Can be set via the UV_USERNAME environment variable.
-p, --password
The password for authentication. Can be set via the UV_PASSWORD environment variable.
-t, --token
The API token for authentication. Can be set via the UV_TOKEN environment variable.
--non-interactive
Do not prompt for any user input during the process.
--dry-run
Performs all steps (build, validate) except the final upload to the registry, allowing for testing.
--no-build
Prevents uv publish from building the distribution files. Assumes that source distributions and wheels are already present.
--sign
Sign the distribution files with GPG before uploading.
--identity
Specify the GPG identity to use for signing.
--config-file
Path to an alternative .pypirc configuration file for repository credentials.
--skip-existing
Skips uploading a package if a version with the same name and version already exists on the target repository.
--verbose
Enable verbose output for more detailed logging during the publishing process.
--quiet
Suppress all non-error output, showing only critical messages.
DESCRIPTION
uv publish is a command within the uv ecosystem designed for building and uploading Python packages to package indexes like PyPI. It streamlines the process of releasing Python projects by integrating package building (creating source distributions and wheels) and uploading functionalities into a single, fast, and reliable command. uv publish aims to be a modern, high-performance alternative to tools like twine, leveraging uv's highly optimized core. It supports various authentication methods, including username/password and API tokens, and allows specifying target repositories. The command handles validation of distributions before upload and offers features like dry runs and GPG signing, making it a comprehensive solution for Python package publication.
CAVEATS
uv publish is part of the uv tool, which is under active development. While stable, new features or behavioral changes might occur.
For security, it's recommended to use environment variables (UV_USERNAME, UV_PASSWORD, UV_TOKEN) or a .pypirc file instead of passing credentials directly on the command line.
Ensure GPG is properly configured on your system if using the --sign option.
AUTHENTICATION METHODS
uv publish supports multiple ways to authenticate with package indexes. Users can provide a username and password directly, use an API token (recommended for PyPI), or leverage credentials defined in a .pypirc file. Environment variables (UV_USERNAME, UV_PASSWORD, UV_TOKEN, UV_REPOSITORY) are also supported for securely passing sensitive information, preventing credentials from appearing in shell history.
BUILD PROCESS
By default, uv publish will attempt to build both a source distribution (.tar.gz) and a wheel distribution (.whl) from the specified PATH (or current directory) if they don't already exist. This ensures that the necessary distribution artifacts are available for upload. The --no-build option can be used to skip this automatic build step if distributions are pre-built, allowing uv publish to simply upload existing files.
HISTORY
The uv project, developed by Astral, emerged as a high-performance alternative to existing Python packaging tools like pip, pip-tools, and virtualenv. Initially focused on dependency resolution, installation, and virtual environment management, uv expanded its capabilities to cover more aspects of the Python development workflow. uv publish was introduced as a natural extension, aiming to provide a fast and unified solution for building and publishing Python packages, thereby reducing the reliance on separate tools like twine and build. Its development is driven by a focus on speed, reliability, and a streamlined user experience, leveraging Rust for performance.