Skip to main content

Overview

uv supports building Python packages into source and binary distributions and uploading them to package registries like PyPI.

Preparing your project

Before publishing, ensure your project is ready for distribution.

Configure a build system

If your pyproject.toml lacks a [build-system] definition, uv won’t build it during uv sync, but will fall back to legacy setuptools during uv build.
We strongly recommend configuring a build system explicitly.
Add a build system to your pyproject.toml:
Read more about build systems.

Building your package

1

Build distributions

By default, this builds both:
  • Source distribution (.tar.gz)
  • Wheel (.whl)
Artifacts are placed in dist/:
2

Build specific directory

3

Build workspace package

When publishing, run uv build --no-sources to ensure the package builds correctly without tool.uv.sources, as other build tools like pypa/build don’t support them.

Updating your version

The uv version command helps manage your package version before publishing.

View current version

See viewing your version for details.

Set exact version

Preview changes

Bump version semantically

Use --bump with version components:

Pre-release versions

Set specific component values

By default, uv version performs lock and sync. Use --frozen to prevent both, or --no-sync to only prevent syncing.

Publishing your package

1

Get credentials

Set PyPI credentials using environment variables or command options:
PyPI no longer supports username/password authentication. Generate a token instead, which is equivalent to --username __token__ with the token as password.
2

Publish to PyPI

For GitHub Actions or other Trusted Publishers, add a trusted publisher to PyPI — no credentials needed!
A complete guide to publishing from GitHub Actions to PyPI is available in the GitHub Guide.

Publishing to custom indexes

Configure custom indexes in pyproject.toml:
Then publish:
When using uv publish --index <name>, pyproject.toml must be present (e.g., include a checkout step in CI).

Handling failed uploads

uv publish retries failed uploads, but if some files upload and others fail:
Retry the same command — existing identical files are ignored:
Use --check-url with the index URL:
uv skips uploading files identical to those in the registry and handles parallel upload races.
Existing files must match exactly. This prevents accidentally publishing distributions with different contents for the same version.

Uploading attestations

uv supports uploading attestations to registries like PyPI.
uv publish doesn’t generate attestations — create them separately before publishing.
uv automatically discovers and matches attestations:
Some third-party indexes may not support attestations and might reject uploads that include them. Use --no-attestations or UV_PUBLISH_NO_ATTESTATIONS to disable if needed.

Testing your package

After publishing, test that it installs correctly:
The --no-project flag avoids using your local project directory.
If you just published, add --refresh-package <PACKAGE> to avoid cached versions.

Complete workflow examples

First-time package release

1

Prepare project

Ensure you have:
  • A configured build system
  • Complete project metadata
  • Tests passing
2

Set version

3

Build distributions

4

Test build

5

Publish to TestPyPI first

6

Test installation

7

Publish to PyPI

Releasing a new version

1

Make your changes

Develop and test new features.
2

Bump version

3

Update changelog

Document changes in CHANGELOG.md.
4

Build and publish

5

Tag release

Publishing from GitHub Actions

1

Set up PyPI trusted publisher

2

Create workflow

.github/workflows/publish.yml
3

Create a release

GitHub Actions automatically builds and publishes.

Best practices

Test on TestPyPI first:
This catches issues without affecting your PyPI release.
Follow SemVer:
  • Major: Breaking changes
  • Minor: New features, backward compatible
  • Patch: Bug fixes
Check what’s included in your distributions:
Use .gitignore and MANIFEST.in to control contents.
Use GitHub Actions or similar for:
  • Automated testing
  • Building on multiple platforms
  • Publishing on release
See the GitHub integration guide.
Maintain a CHANGELOG.md and create GitHub releases with notes.

Next steps

PyPA build guide

Official Python packaging guides

Integration guides

Integrate uv with other tools

GitHub integration

CI/CD with GitHub Actions

Build systems

Configure build systems