pypa / flit

Simplified packaging of Python modules
https://flit.pypa.io/
BSD 3-Clause "New" or "Revised" License
2.14k stars 130 forks source link

Look for PyPI tokens in keyring when uploading #649

Closed takluyver closed 8 months ago

takluyver commented 1 year ago

The username for keyring should look like pypi_token:project:<project_name> (using the normalised name), or pypi_token:user:<username>. If neither are found, it falls back to looking for a password (but if you have 2FA enabled on PyPI, uploads have to use tokens now).

I'd like to make some more tooling for conveniently creating tokens, but there isn't a PyPI API for it yet.

While I'm looking at this code, I've also simplified things a bit so that FLIT_USERNAME and FLIT_PASSWORD environment variables override details in .pypirc even if you use --repository, and it figures out the repository details before building the packages.

takluyver commented 1 year ago

I'm going to try this branch the next time I have a package to upload, before I merge it.

takluyver commented 8 months ago

I forgot about this for a long while, and then for a while longer I didn't upload any packages through Flit. Now I just have again, and putting a token in my keyring with username pypi_token:project:pep517 worked. :-)