7

tl;dr - How do I upload a new release to a TestPyPi project?

Description: I followed these instructions in the Python Package User Guide to import a test package to TestPyPi. However, the package I uploaded has an error. I corrected the error and tried to overwrite the package, but encountered the following error:

Code:

python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Error:

HTTPError: 400 Client Error: File already exists. See https://test.pypi.org/help/#file-name-reuse for url: https://test.pypi.org/legacy/

On stack overflow, I found a post stating that a TestPyPi package cannot be overwritten. However, TestPyPi itself indicates that version release should be possible.

When I searched TestPyPi for documentation, I cannot find anything stating how to upload a new version of a package. In one area I found a brief reference to release management, but it is a hyperlink that links to the instructions on how to install a package, not update one (this is the same hyperlink I referenced in the first sentence of this post).

How do I upload a new release to a TestPyPi project?

Jwok
  • 646
  • 9
  • 23
  • Possible duplicate of [How to upload new versions of project to PyPI with twine?](https://stackoverflow.com/questions/52016336/how-to-upload-new-versions-of-project-to-pypi-with-twine) – Dustin Ingram Jul 01 '19 at 22:53

2 Answers2

10

You need to increase the version in setup.py and rerun setup.py; e.g. python3 setup.py sdist bdist_wheel or similar. Good idea to rm -rf dist build and remove the egg-info file too.

You cannot just resubmit the same packaged name and version, it does not auto-overwrite and you can understand why if you think about it logically, if the code changes, you would never want to overwrite a current version that people rely on, because it could break their instance of it, so you practice as you play in test to ensure that you get into good habits.

james-see
  • 12,210
  • 6
  • 40
  • 47
  • 10
    for sure people rely on pip and versions, but why is it the case for the test PyPi – pltrdy Oct 01 '19 at 16:53
  • 5
    @pltrdy probably for lame reason, like the same code runs on pypi and testpypi, so the same restrictions apply. It's a bit annoying because testpypi should allow to play with it without bumping the version… – Cyrille Pontvieux Jan 09 '20 at 20:49
6

TestPyPI and even PyPI itself have had ability to reuse filenames. But after switching to Warehouse (the new code behind PyPI and TestPyPI) they lost that ability. There is no way to reupload the same filename.

Increase version, regenerate packages and upload new packages with new names.

phd
  • 82,685
  • 13
  • 120
  • 165
  • 1
    "Increase version" sounds like the way to address my question, although I don't know what "regenerate packages" means. How do I do a version increase, and what is package regeneration? – Jwok Jun 10 '19 at 16:12
  • 4
    Increase version in `setup.py`, cleanup `dist/` directory, run the same commands you've used to create distributions for the first time. – phd Jun 10 '19 at 17:43