Add Publish A Package To A Test Env As A Dry Run as a Python TIL

This commit is contained in:
jbranchaud
2026-08-06 19:28:35 -05:00
parent b484204c2f
commit eb419752c4
2 changed files with 37 additions and 1 deletions
+2 -1
View File
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
_1852 TILs and counting..._
_1853 TILs and counting..._
See some of the other learning resources I work on:
@@ -1111,6 +1111,7 @@ If you've learned something here, support my efforts writing daily TILs by
- [Make Secure Temp File For Atomic Write](python/make-secure-temp-file-for-atomic-write.md)
- [Override The Boolean Context Of A Class](python/override-the-boolean-context-of-a-class.md)
- [Parse Relative Time To datetime Object](python/parse-relative-time-to-datetime-object.md)
- [Publish A Package To A Test Env As A Dry Run](python/publish-a-package-to-a-test-env-as-a-dry-run.md)
- [Reclassify Certain Packages As Dev Dependencies](python/reclassify-certain-packages-as-dev-dependencies.md)
- [Resurface Exceptions Swallowed By Click Under Test](python/resurface-exceptions-swallowed-by-click-under-test.md)
- [Select Implementation With Class Registry](python/select-implementation-with-class-registry.md)
@@ -0,0 +1,35 @@
# Publish A Package To A Test Env As A Dry Run
As I was preparing to register a new Python package with PyPI and release my
first version cut, I felt like there were a lot of unknowns. Is my package's
name going to be valid? How will the package appear in PyPI? Did I configure
everything correctly? Etc.
It turns out that PyPI has a great way of answering a lot of these questions.
There is a [`test.pypi.org`](https://test.pypi.org/) site that parrots the
publishing flow of `pypi.org`. This makes for a great target to do a dry-run
publishing of a package.
First, I had to go through the same registration flow and 2FA setup as when I
registered with `pypi.org`.
Second, I deviated from my tag and CI-triggered publishing flow by instead doing
a one-off run of the `uv publish` command. That requires an API token which I
generated in the web UI for `test.pypi.org`. I added that to my env as
`TEST_PYPI_TOKEN`.
I then ran the following command:
```bash
uv publish --publish-url https://test.pypi.org/legacy/ --token "$TEST_PYPI_TOKEN"
```
When this first ran for [`py-vmt`](https://github.com/jbranchaud/py-vmt), I got
an error back from the publishing API telling me the package name is too similar
to an existing package. I then had to make a few updates across the project to
rename the published package name to `visualmode-tracker`. Running the `uv
publish` command again worked with the updated name.
I was then able to go into the web UI and verify everything looked as expected.
I now have the confidence to publish this thing for real to `pypi.org`.