Twine 不允许我注册或上传我的包裹:https://upload.pypi.org/legacy/ 错了吗?

Twine won't let me register or upload my package: is https://upload.pypi.org/legacy/ wrong?

我有一个 Python package that I am trying to register on PyPI. I am trying to do this with the latest version of twine (1.9.1) and following the instructions on the twine webpage.

我在本地正确配置了我的包。 (setup.py 是完整的等等。)该名称尚未在 PyPI 上声明。我在 PyPI 上有一个帐户。我的机器上没有 ~/.pypirc 文件。我已经构建了一个源代码分发和一个轮子。

> ll dist
total 64
-rw-r--r--  1 billmcn  staff  14184 Aug  1 13:35 mycroft-1.1.0.tar.gz
-rw-r--r--  1 billmcn  staff  15996 Aug  1 13:36 mycroft-1.1.0-py3-none-any.whl

当我尝试注册这些软件包中的任何一个时,我收到以下错误消息。

> twine register dist/mycroft-1.1.0.tar.gz 
Registering package to https://upload.pypi.org/legacy/
Enter your username: billmcn
Enter your password: 
Registering mycroft-1.1.0.tar.gz
HTTPError: 410 Client Error: Project pre-registration is no longer required or supported, so continue directly to uploading files. for url: https://upload.pypi.org/legacy/

我尝试注册 wheel 文件时收到相同的错误消息。这让我觉得这个注​​册步骤是不必要的。但是,当我尝试上传我的包裹时,我看到了这个。

> twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: billmcn
Enter your password: 
Uploading mycroft-1.1.0-py3-none-any.whl
[================================] 23132/23132 - 00:00:00
HTTPError: 403 Client Error: You are not allowed to upload to 'mycroft'. for url: https://upload.pypi.org/legacy/

如果您在尝试上传包之前未能注册您的包,这看起来像是您收到的错误。当我在 PyPI 站点上 browse for it 时,我没有看到我的包。所以我卡住了。

我觉得 https://upload.pypi.org/legacy/ 有点可疑。我应该指定其他一些 URL 吗?

如何注册我的包裹?


这看起来类似于 . The issue there was that the person had an invalid url keyword argument in their setup.py:setup function. However, my URL is the project's github page, https://github.com/wpm/mycroft,并且是正确的。

如果我有以下 ~/.pypirc 文件,我会遇到同样的问题:

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
username=billmcn
password=********

[pypitest]
username=billmcn
password=********

各种尝试手动指定上传URL.

twine upload dist/* -r https://pypi.python.org/pypi
KeyError: Missing 'https://pypi.python.org/pypi' section from the configuration file
or not a complete URL in --repository.
Maybe you have a out-dated '~/.pypirc' format?
more info: https://docs.python.org/distutils/packageindex.html#pypirc

--help 文字说 twine 应该能够判断我是在指定存储库名称还是 URL,但让我们明确一点。

> twine upload dist/* --repository-url https://pypi.python.org/pypi
Uploading distributions to https://pypi.python.org/pypi
Note: you are uploading to the old upload URL. It's recommended to use the new URL "https://upload.pypi.org/legacy/" or to leave the URL unspecified and allow twine to choose.
Enter your username: billmcn
Enter your password: 
Uploading mycroft-1.1.0-py3-none-any.whl
HTTPError: 410 Client Error: Gone (This API has been deprecated and removed from legacy PyPI in favor of using the APIs available in the new PyPI.org implementation of PyPI (located at https://pypi.org/). For more information about migrating your use of this API to PyPI.org, please see https://packaging.python.org/guides/migrating-to-pypi-org/#uploading. For more information about the sunsetting of this API, please see https://mail.python.org/pipermail/distutils-sig/2017-June/030766.html) for url: https://pypi.python.org/pypi

所以我应该使用 "new" URL https://upload.pypi.org/legacy/?

> twine upload dist/* --repository-url https://upload.pypi.org/legacy/
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: billmcn
Enter your password: 
Uploading mycroft-1.1.0-py3-none-any.whl
HTTPError: 403 Client Error: You are not allowed to upload to 'mycroft'. for url: https://upload.pypi.org/legacy/                                                               

我被难住了。而且我找不到当前正确 URL.

的任何官方来源

我想让 twine 工作,因为 Python documentation recommends against 使用 python setup.py registerpython setup.py upload

无论如何我都试过了,运行 看起来是同样的问题。

> python setup.py register
running register
running egg_info
writing mycroft.egg-info/PKG-INFO
writing dependency_links to mycroft.egg-info/dependency_links.txt
writing entry points to mycroft.egg-info/entry_points.txt
writing requirements to mycroft.egg-info/requires.txt
writing top-level names to mycroft.egg-info/top_level.txt
reading manifest file 'mycroft.egg-info/SOURCES.txt'
writing manifest file 'mycroft.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]: 

Username: billmcn
Password: 
Registering mycroft to https://upload.pypi.org/legacy/
Server response (410): Project pre-registration is no longer required or supported, so continue directly to uploading files.

> python setup.py sdist bdist_wheel upload
...builds the packages...
running upload
Password: 
Submitting dist/mycroft-1.1.0.tar.gz to https://upload.pypi.org/legacy/
Upload failed (403): You are not allowed to upload to 'mycroft'.
error: Upload failed (403): You are not allowed to upload to 'mycroft'.

打开 PyPI issue #677

对你来说很遗憾,即使它看起来是空的并且没有任何代码,看起来 PyPI 上已经有一个 'mycroft' 包:https://pypi.python.org/pypi/mycroft/0.1.0。这就是 api 告诉您您无权使用此包名称的原因。

它可能来自旧版本的 pypi,因为它甚至没有默认版本。这可能就是无法通过研究工具找到它的原因。我能够使用 json api 找到它:https://pypi.python.org/pypi/mycroft/json

我不知道 pypi 对此的政策,但也许他们可以删除它,因为即使 GitHub 也会抛出 404。使用新的 [=19] 可能不会接受该包上传=] 无论如何。