Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload a new release to TestPyPi

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?

like image 574
Jwok Avatar asked Dec 14 '22 11:12

Jwok


1 Answers

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.

like image 90
jamescampbell Avatar answered Dec 31 '22 19:12

jamescampbell