2

我正在尝试使用twine upload dist/*命令上传我的包。我得到一个错误:

Client Error: 'X.Y.ZZ.post0.dev0-g83905ac' is an invalid value for Version. Error:

在我看来,该X.Y.ZZ.post0.dev0-g83905ac版本确实满足PEP 440。我不明白发生了什么事。

我已经创建了 annotetade 标签等。我想我已经创建了标签。

$ git tag -a vX.Y.ZZ  # Don't forget the leading v
fatal: tag 'vX.Y.ZZ' already exists

我注意到 sdist 命令返回错误:

user:package user-13$ python3 setup.py sdist
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/dist.py:483: UserWarning: The version specified ('X.Y.ZZ.post0.dev0+g83905ac') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  "details." % self.metadata.version

我确实拥有所有东西的最新版本:

user:package user-13$ pip3 --version
pip 19.2.3 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
user: package femto-13$ python3 --version
Python 3.7.4
user: package femto-13$ twine --version
twine version 1.14.0 (pkginfo: 1.5.0.1, requests: 2.22.0, setuptools: 41.2.0,
requests-toolbelt: 0.9.1, tqdm: 4.35.0)

历史:

  917  git tag -a vX.Y.ZZ  # Don't forget the leading v
  918  git push origin vX.Y.ZZ
  919  python3 setup.py sdist
  920  python3 setup.py bdist_wheel
  921  twine upload dist/*

这是 twine 命令的结果:

user:package user-13$ twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading py_package-X.Y.ZZ.post0.dev0_g83905ac-py3-none-any.whl
100%|███████████████████████████████████████████████████████████████████████| 18.5k/18.5k [00:00<00:00, 37.9kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 400 Client Error: 'X.Y.ZZ.post0.dev0-g83905ac' is an invalid value for Version. Error: Start and end with a letter or numeral containing only ASCII numeric and '.', '_' and '-'. See https://packaging.python.org/specifications/core-metadata for url: https://upload.pypi.org/legacy/

我已将标签更新为 0.0.1 并删除了所有 XYZ 标签。

4

1 回答 1

3

该版本X.Y.ZZ.post0.dev0-g83905ac不是 PyPI 的有效版本号。它包含一个提交哈希g83905acPEP 440说:

许多构建工具与 Git 和 Mercurial 等分布式版本控制系统集成,以便为版本标识符添加识别哈希。由于无法可靠地对哈希进行排序,因此公共版本字段中不允许使用此类版本。

于 2019-09-20T03:37:15.767 回答