Twine 每次都要求我输入密码:如何使用 .pypirc

jav*_*dba 12 python setuptools twine

我已经pip安装pypirc并设置了一个~/.pypirc带有必需密码的文件。为什么twine每次python setup.py调用都要求输入密码?

  $twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  Enter your username:
Run Code Online (Sandbox Code Playgroud)

这是表格的形式 .pypirc

[distutils] # this tells distutils what package indexes you can push to
index-servers =
  pypi
  pypitest

[pypi]
repository: https://pypi.python.org/pypi
username: myuser 
password: mypwd 

[pypitest]
repository: https://testpypi.python.org/pypi
username: myuser 
password: mypwd 
Run Code Online (Sandbox Code Playgroud)

更新不包括--repository-url给予:

UploadToDeprecatedPyPIDetected: You're trying to upload to the legacy PyPI site 'https://pypi.python.org/pypi'. Uploading to those sites is deprecated.
 The new sites are pypi.org and test.pypi.org. Try using https://upload.pypi.org/legacy/ (or https://test.pypi.org/legacy/) to upload your packages instead. These are the default URLs for Twine now.
 More at https://packaging.python.org/guides/migrating-to-pypi-org/ .
Run Code Online (Sandbox Code Playgroud)

phd*_*phd 13

twine upload dist/*
Run Code Online (Sandbox Code Playgroud)

或者

twine upload -r pypi dist/*
Run Code Online (Sandbox Code Playgroud)

或者

twine upload -r pypitest dist/*
Run Code Online (Sandbox Code Playgroud)

据我了解twine --repository-url <url>,甚至没有咨询~/.pypirc。使用-r <name>它查找~/.pypircURL、用户名和密码。如果省略-r <name>,twine 将使用~/.pypirc.

  • 在`~/.pypirc`中:`存储库:https://upload.pypi.org/legacy/`或`存储库:https://test.pypi.org/legacy/`。 (2认同)