Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for PyPI tokens in keyring when uploading #649

Merged
merged 4 commits into from
Nov 8, 2023
Merged

Conversation

takluyver
Copy link
Member

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
Copy link
Member Author

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

Copy link
Contributor

@Carreau Carreau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should try that as well next time to make sure it works on MacOS

flit/upload.py Outdated
url: str
username: Optional[str] = None
password: Optional[str] = None
is_warehouse: bool = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to update that naming to is_legacy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_pypi might be a better name now - it's distinguishing PyPI (the new site, aka Warehouse) from other servers like devpi, and originally from PyPI classic.

It's only used for the 'Package is at' log message, so it's not too important that it's always right.

flit/upload.py Show resolved Hide resolved
@takluyver
Copy link
Member Author

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. :-)

@takluyver takluyver merged commit 06b9e2e into main Nov 8, 2023
15 of 16 checks passed
@takluyver takluyver deleted the keyring-tokens branch November 8, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants