4
votes

I followed the official documentation for uploading packages to PyPI, as well as the information provided in PyPI readme, but I get a HTTP 400 error each time:

$ twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/ 
Enter your username: bradaallen
Enter your password:
Uploading brad_nlp_helpers-0.1.1-py3-none-any.whl
HTTPError: 400 Client Error: home_page: Invalid URI for url: 
https://upload.pypi.org/legacy/

I am using a ~/.pypirc

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
username=bradaallen
password=[password]

[pypitest]
username=bradaallen
password=[password]

For packages, I am using twine version 1.9.1 (pkginfo: 1.4.1, requests: 2.12.4, setuptools: 27.2.0, requests-toolbelt: 0.8.0, tqdm: 4.14.0)

When I use python setup.py sdist bdist_wheel upload I get the same issue:

Submitting dist\brad_nlp_helpers-0.1.1.tar.gz to
https://upload.pypi.org/legacy/ Upload failed (400): home_page: Invalid URI
error: Upload failed (400): home_page: Invalid URI

I have not specified the repository, as that is recommendation that is given by the API when uploading. I am seeing a 404 error at the link that PyPI recommends and am not seeing an alternative site I should use!

This is my first package, and I am not seeing this error elsewhere on the internet. Any thoughts re: what's going on?

3
I just visited the page upload.pypi.org/legacy and got error 404 (not exists). What version of twine do you use? May be you need to create .pypirc?…phd
Hi @phd - thanks for your comment. I've updated the version of twine and .pypirc data I used. I also noticed the website does not exist - it is the URL recommended by the PyPI API. I am not seeing this problem elsewhere, which makes me wonder if it is a recent issue with PyPI. Thoughts?Brad Allen
No idea. I created .pypirc 15 years ago and have been happily using python setup.py upload ever after. :-)))phd
@phd :) - I get the same issue with python setup.py sdist bdist_wheel upload. I just ran that code and got this error: Submitting dist\brad_nlp_helpers-0.1.1.tar.gz to https://upload.pypi.org/legacy/ Upload failed (400): home_page: Invalid URI error: Upload failed (400): home_page: Invalid URIBrad Allen
You don't have https://upload.pypi.org/legacy/ in .pypirc, do you?! PS. I switched to twine a year ago, no problems so far.phd

3 Answers

2
votes

Amazing. I also posted this as an Issue on Twine's GitHub page.

It turns out the URL in the setup.py file should correspond to where the code is being hosted (which makes sense). I had put my personal website as the URL and I guess the unit tests at Warehouse were rejecting me... it's now uploaded.

Thank you again @phd!

0
votes

Just a few minutes ago tried to upload a package and got this problem. :-) To fix: upgrade pip, setuptools and twine to the very latest versions:

pip install -U pip setuptools twine

Remove or comment out repository from ~/.pypirc:

[distutils]
index-servers =
    pypi

[pypi]
#repository: 
username: …

twine upload now works!

-1
votes

When you use README.md file as long_description in the setup.py, some strings such as ".*" do not support in PyPI. So, there is a need to remove them and rebuild the WHL file and upload it again by twine.