Skip to content

Make it easier to retry in upload-pypi script #19174

Open
@JukkaL

Description

@JukkaL
Collaborator

Recently the misc/upload-pypi.py script failed several times while I was uploading a release. It succeeded in uploading some wheels, but it failed at some point. It's possible to run it multiple times to work around the issue, but this is not ideal since it repeats all the work. Here some ideas about how to make this better:

  • If upload fails, ask if the user wants to try uploading again. This would help by not having to download the wheels again.
  • If upload fails, ask if the user wants to try uploading again, but only upload the wheels which haven't been successfully uploaded so far.
  • Automatically retry, without asking for the pypi token/secret again.

Any of these would be an improvement over the current situation, but the first option might not help much if the script will just repeatedly fail at some point.

Activity

webknjaz

webknjaz commented on May 30, 2025

@webknjaz

On a related note, have you considered getting MyPy green on https://trailofbits.github.io/are-we-pep740-yet/ ?

This would require publishing from GHA: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/.

(of course, the in-repo script is still good to retain as a backup method)

P.S. There's a (kinda) related discussion @ pypa/twine#1246 in the context of a PyPI token expiring while Twine is in the process of uploading large amounts of big wheels when PyPI/network is flaky. Not exactly your case because that one is GHA-specific (GHA+Trusted Publishing), but feel free to contribute some thoughts if any.


If upload fails, ask if the user wants to try uploading again, but only upload the wheels which haven't been successfully uploaded so far.

For this specific point, you can stick a --skip-existing into the twine upload command, and it'll have it do the thing: https://github.com/python/mypy/blob/409d294/misc/upload-pypi.py#L111. Beyond that, you don't really have much control since all the wheels are being passed to Twine and its internals are doing the looping.

sterliakov

sterliakov commented on May 30, 2025

@sterliakov
Collaborator

I'm a huge +1 on publishing from GHA. That isn't difficult (I have a couple workflows doing that), but ultimately depends on maintainers' stance: if they don't trust GitHub to store a PyPI toke granting access to such a popular project, it simply won't happen. And I can understand such lack of trust because Microsoft.

emmatyping

emmatyping commented on Jun 1, 2025

@emmatyping
Member

I agree publishing via GitHub Actions is a good idea both for robustness and attestation purposes. It also was brought up as a step towards reducing the amount of work needed to onboard new RMs if I recall correctly.

added a commit that references this issue on Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @webknjaz@JukkaL@emmatyping@sterliakov

        Issue actions

          Make it easier to retry in upload-pypi script · Issue #19174 · python/mypy