-
uv publish
First, add the Test PyPI index configuration to your
pyproject.tomlunder the[tool.uv.index]section:[[tool.uv.index]] name = "testpypi" url = "https://test.pypi.org/simple/" publish-url = "https://test.pypi.org/legacy/" explicit = true
Then, you can publish your package to Test PyPI using the following command:
uv publish --index testpypi --token $TEST_PYPI_API_TOKEN$TEST_PYPI_API_TOKENis your Test PyPI API token stored in your environment variables. -
uv install test package from Test PyPI
First, create a new virtual environment for testing.
uv venv .venv-test source .venv-test/bin/activateThen, install your package (
publish_python_package101in this case) from Test PyPI.uv pip install --index-url https://test.pypi.org/simple publish_python_package101
I use
uv pip installjust because I don't want to manage dependencies with uv in.venv-test -
check installation
python -c "import publish_python_package101; print(publish_python_package101.__version__)" python example/getting_started.pyYou should see the version number of your package printed out.
-
Publish after version up
Before publishing to TestPyPI / PyPI, make sure to update the version number in
pyproject.toml. For example, if the current version is0.1.0, change it to0.1.1or any other appropriate version number.After updating the version number, just make sure your distribution files are up to date by running:
rm -rf dist/ uv build