Using uv to publish Python packages

Publishing uv packages

语速
1
2
3
[build-system]
requires = ["setuptools>=42", "wheel", "uv>=0.6.0"]
build-backend = "setuptools.build_meta"
1
uv build
1
python -m twine upload
1
2
3
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
1
2
3
4
5
6
[tool.pdm]
distribution = true

[tool.pdm.version]
source = "file"
path = "src/spback/__init__.py"

Since migrating from pdm to uv, besides dependency management, I also wanted to use uv for publishing packages.

Method 1

LLMs provided a solution, suggesting to add the following content in pyproject.toml:

After adding this content, we run:

Then run:

The package can then be published.

Method 2

Since there are many projects using pdm, directly modifying pdm can also cause significant inconvenience.

You can still use pdm as the build-system but use uv as the package management tool.

In other words:

even

Some Thoughts

LLMs are already quite powerful. However, LLMs cannot guarantee the accuracy of generated content, requiring human verification. Therefore, the human who verifies the output is essential.

This code must be verified by a human to work. Of course, if it’s merely about modifying content, LLMs can collaborate with us, in the form of a cursor.