我想使用 twine 将项目构建上传到 test.pypi.org。我正在遵循 twine GitHub page 中基本用例的自述文件。 。我已经安装了最新版本的 twine:
$ twine --version
twine version 1.5.0 (pkginfo: 1.2.1, requests: 2.9.1, setuptools: 20.7.0)`
但是当我尝试上传构建的项目时,出现以下错误:
$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*
usage: twine upload [-h] [-r REPOSITORY] [-s] [--sign-with SIGN_WITH]
[-i IDENTITY] [-u USERNAME] [-p PASSWORD] [-c COMMENT]
dist [dist ...]
twine upload: error: unrecognized arguments: --repository-url
这正是 Python Packaging Tutorial 上引用的代码行Twine README 和 --repository-url 应该是一个有效的标志。这是传递给标志而不是标志本身的参数的错误吗?如果是这样,我需要修复什么?
我的项目的 setup.py 文件:
import setuptools
with open('README.md', 'r') as fh:
long_description = fh.read()
setuptools.setup(
name='MyPackageName',
version='0.1.0',
author='J. Chamness',
author_email='<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9d4c0fcd4d8d0d5f9ded4d8d0d597dad6d4" rel="noreferrer noopener nofollow">[email protected]</a>',
description='MyDescription',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://test.pypi.org/legacy/',
packages=setuptools.find_packages(),
classifiers=(
'Programming Language :: Python :: 3',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Operating System :: OS Independent',
),
)
最佳答案
您正在使用旧版本的 twine (1.5.0)。如@phd observes , --repository-url 在版本 1.8 中添加到 twine 中。升级到最新版本以获得此功能:
pip install --upgrade twine
关于python - Twine 无法识别 --repository-url 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51126774/