I want to automate the upload process bug in some cases the python setup.py upload
fails because pypi server already have the save version uploaded.
How can I force it to upload, from the script (i know I can remove the old variant using the web interface).
A late answer, but: it seems everybody agrees you can't overwrite existing pypi uploads, or re-upload a fixed version after you delete a broken version. However, it seems actually possible and officially supported: "build numbers" are a feature that nobody has ever used or remembers they exist, but that seems to work, at least for me.
The trick is to rename the files in the following pattern:
mypackage-0.31.0-py2.py3-none-any.whl mypackage-0.31.0-1-py2.py3-none-any.whl mypackage-0.31.0-2-py2.py3-none-any.whl
The "-1" or "-2" are build numbers. If pip finds all these files for the same release, it will pick the one with the highest build number. It also seems to work if it finds only a single file with a non-zero build number, so you can use that after you deleted the original.
(This is very quickly mentioned in the documentation at https://www.python.org/dev/peps/pep-0427/#file-name-convention but I wouldn't have guessed its use without Daniel Holth pointing it out to me. Thanks Daniel!)
I have no idea why the internet contains so many people convinced it can't be done. I myself only learned about it yesterday and thought I should try to pass on that information.
Insert here the usual warning about not to abuse that feature. A typical example for when I think you should use this is after one of the wheels was badly built and you need to replace it with a correctly-built wheel from the same sources
Here's an actual answer, not just me adding more pontification in the comments. Found this thread:
https://www.reddit.com/r/Python/comments/35xr2q/howto_overwrite_package_when_reupload_to_pypi/
That refers to this:
http://comments.gmane.org/gmane.comp.python.distutils.devel/22739
Saying it can't be done.
Also note the comment in the reddit thread about reading semver.org and incrementing the micro version for patches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With