我如何使用python setup.py上传?

时间:2017-08-26 07:53:02

标签: python pypi python-packaging

我正在尝试将包上传到PyPI - 但我似乎无法。尝试上传失败:

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

但我已经创建了一个dist文件!

然后我发现了一个有问题的问题 - 接受的答案是python setup.py sdist upload,但仍然无效:

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.

由于我认为这可能与此无关,因此我使用了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.

由于它说“继续直接上传文件”,我接着尝试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.

因此,由于不再需要注册,我对sdist upload做错了什么?我应该输入我的PyPI密码(我正在尝试的东西)或其他东西,还是我需要先做一个单独的事情?

1 个答案:

答案 0 :(得分:-3)

我使用的是Linux而且twine工作正常 - 我必须在Windows上搞砸了一些东西。这已经解决了!

一旦PyPI从https://pypi.org迁移到https://pypi.python.org,大多数问题也应该得到解决。