我已经安装了pip
pypirc
,并使用必需的密码设置了~/.pypirc
文件。为什么twine
每次调用python setup.py
时都要求输入密码?
$twine upload --repository-url https://test.pypi.org/legacy/ dist/*
Enter your username:
这里是.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
更新(不包括--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/ .
答案 0 :(得分:2)
twine upload dist/*
或
twine upload -r pypi dist/*
或
twine upload -r pypitest dist/*
据我了解,twine --repository-url <url>
甚至没有咨询~/.pypirc
。使用-r <name>
,它会在~/.pypirc
中查找URL,用户名和密码。如果省略-r <name>
,则twine将使用~/.pypirc
中的第一个存储库。
答案 1 :(得分:0)
我对最终答案很好奇。我遇到了完全相同的问题。
我在主文件夹中有一个包含以下内容的 .pypirc,但在 twine upload -r pypi dist/*
时,它仍然要求提供凭据。
[distutils]
index-servers =
pypi
testpypi
Amplo
[pypi]
username: __token__
password: ***
[testpypi]
username: __token__
password: ***
[Amplo]
repository: https://upload.pypi.org/legacy/
username: __token__
password: ***