在 PyPI 测试站点命令行注册 ValueError

Registering on PyPI test site command line ValueError

为什么当我尝试在测试站点注册我的包时会出现以下情况?它在常规站点上注册就好了:/

这是我尝试注册 pypi 测试站点时在命令行中发生的情况:

PS C:\Users\Dave\Desktop\distributing\hellodmt2Distribution> python setup.py register -r https://testpypi.python.org
i
running register
running egg_info
writing hellodmt2.egg-info\PKG-INFO
writing top-level names to hellodmt2.egg-info\top_level.txt
writing dependency_links to hellodmt2.egg-info\dependency_links.txt
reading manifest file 'hellodmt2.egg-info\SOURCES.txt'
writing manifest file 'hellodmt2.egg-info\SOURCES.txt'
Traceback (most recent call last):
  File "setup.py", line 14, in <module>
    download_url = "https://github.com/dmt257/hellodmt2/archive/0.1.tar.gz",
  File "C:\Python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\site-packages\setuptools\command\register.py", line 10, in run
    orig.register.run(self)
  File "C:\Python27\lib\distutils\command\register.py", line 46, in run
    self._set_config()
  File "C:\Python27\lib\distutils\command\register.py", line 81, in _set_config
    raise ValueError('%s not found in .pypirc' % self.repository)
ValueError: https://testpypi.python.org/pypi not found in .pypirc
PS C:\Users\Dave\Desktop\distributing\hellodmt2Distribution>

我的setup.py:

#!/usr/bin/env
try:
    from setuptools import setup
except importError:
    from distutils.core import setup

setup(name = "hellodmt2",
      description = "a source distribution test",
      version = "0.1",
      author = "David",
      author_email = "dmt257257@gmail.com",
      py_modules = ["hellodmt2"],
      url = "https://github.com/dmt257/hellodmt2",
      download_url = "https://github.com/dmt257/hellodmt2/archive/0.1.zip",
      keywords = ["testing"],

      )

这是我的pypirc:

    [distutils]
index-servers=
    pypi
    pypitest

[pypitest]
repository = https://testpypi.python.org/pypi
username = dmt257
password = mypasswordhere

[pypi]
repository = https://pypi.python.org/pypi
username = dmt257
password = mypasswordhere

该文件应该简单地称为 .pypirc,而不是 pypi.pypirc。这是配置文件常用的 Linux 风格的文件名。前导点表示它不会显示在普通目录列表中。

根据我的阅读,Windows 相当于 Linux $Home 目录 (~) 是 C\Users\<logged-in-user>,因此 C\Users\Dave,在你的情况下。将位置添加到 PATH 中无济于事;此变量仅允许 Windows 查找可执行文件。

文档不清楚这个文件应该放在 Windows 环境中的什么地方,有一个旧的 bug 提到这个文件在 Windows 中找不到,因为缺少 HOME 环境变量。已经 'fixed' 但仍然不清楚文件应该去哪里,除了 ~/.pypirc

我会先尝试重命名您的文件。如果仍有问题,请尝试将其移至 'home' 目录。请注意,Windows GUI 不允许您重命名仅具有扩展名的文件,因此您必须通过命令 window:

进行重命名

rename pypi.pypirc .pypirc