Search code examples
pythonpypipython-packaging

How do I use python setup.py upload?


I'm trying to upload a package to PyPI - but I can't seem to. Trying to upload failed:

C:\pphp>python setup.py upload
running upload
Password:
error: No dist file created in earlier command

but I had already created a dist file!

I then found a question that had that problem - the accepted answer was python setup.py sdist upload, which still didn't work:

C:\pphp>python setup.py sdist upload
running sdist
running egg_info
writing pphp.egg-info\PKG-INFO
writing top-level names to pphp.egg-info\top_level.txt
writing dependency_links to pphp.egg-info\dependency_links.txt
reading manifest file 'pphp.egg-info\SOURCES.txt'
writing manifest file 'pphp.egg-info\SOURCES.txt'
running check
creating pphp-1.2.2a1
creating pphp-1.2.2a1\pphp.egg-info
copying files to pphp-1.2.2a1...
copying README.rst -> pphp-1.2.2a1
copying setup.py -> pphp-1.2.2a1
copying pphp.egg-info\PKG-INFO -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\SOURCES.txt -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\dependency_links.txt -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\top_level.txt -> pphp-1.2.2a1\pphp.egg-info
Writing pphp-1.2.2a1\setup.cfg
Creating tar archive
removing 'pphp-1.2.2a1' (and everything under it)
running upload
Password: (my pypi pass)
Submitting dist\pphp-1.2.2a1.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

Since I assumed this had to do with this probably not being registered, I used python setup.py register:

C:\pphp>python setup.py register
running register
running egg_info
writing pphp.egg-info\PKG-INFO
writing top-level names to pphp.egg-info\top_level.txt
writing dependency_links to pphp.egg-info\dependency_links.txt
reading manifest file 'pphp.egg-info\SOURCES.txt'
writing manifest file 'pphp.egg-info\SOURCES.txt'
running check
We need to know who you are, so please choose either:
 1. use your existing login,
 2. register as a new user,
 3. have the server generate a new password for you (and email it to you), or
 4. quit
Your selection [default 1]:
1
Username: (my pypi username)
Password: (password)
Registering pphp to https://upload.pypi.org/legacy/
Server response (410): Project pre-registration is no longer required or supported, so continue directly to uploading files.

Since it said "continue directly to uploading files", I then tried sdist register upload:

C:\pphp>python setup.py sdist register upload
running sdist
running egg_info
writing pphp.egg-info\PKG-INFO
writing top-level names to pphp.egg-info\top_level.txt
writing dependency_links to pphp.egg-info\dependency_links.txt
reading manifest file 'pphp.egg-info\SOURCES.txt'
writing manifest file 'pphp.egg-info\SOURCES.txt'
running check
creating pphp-1.2.2a1
creating pphp-1.2.2a1\pphp.egg-info
copying files to pphp-1.2.2a1...
copying README.rst -> pphp-1.2.2a1
copying setup.py -> pphp-1.2.2a1
copying pphp.egg-info\PKG-INFO -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\SOURCES.txt -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\dependency_links.txt -> pphp-1.2.2a1\pphp.egg-info
copying pphp.egg-info\top_level.txt -> pphp-1.2.2a1\pphp.egg-info
Writing pphp-1.2.2a1\setup.cfg
Creating tar archive
removing 'pphp-1.2.2a1' (and everything under it)
running register
We need to know who you are, so please choose either:
 1. use your existing login,
 2. register as a new user,
 3. have the server generate a new password for you (and email it to you), or
 4. quit
Your selection [default 1]:
1
Username: (username)
Password: (password)
Registering pphp to https://upload.pypi.org/legacy/
Server response (410): Project pre-registration is no longer required or supported, so continue directly to uploading files.
running upload
Password: (password)
Submitting dist\pphp-1.2.2a1.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent authentication information.

So since registration is no longer needed, what am I doing wrong with sdist upload? Am I supposed to enter my PyPI password (what I'm trying) or something else, or is there a separate thing I need to do first?


Solution

  • I used Linux instead and twine worked fine - there must have been something I messed up on Windows. This has been resolved!

    Most questions like this should also be solved once PyPI migrates to https://pypi.org from https://pypi.python.org as well.