python
data_error
ai_generated
true
ValueError:无效版本:'1.0.0-beta'
ValueError: Invalid version: '1.0.0-beta'
ID: python/setuptools-metadata-version-invalid
80%修复率
89%置信度
0证据数
2024-03-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
setuptools 根据 PEP 440 校验版本字符串。'1.0.0-beta' 使用了连字符,这是不允许的;PEP 440 使用 'b' 表示 beta,例如 '1.0.0b0'。预发布分隔符必须规范化。
English
setuptools validates the version string against PEP 440. '1.0.0-beta' uses a hyphen which is not allowed; PEP 440 uses 'b' for beta, e.g. '1.0.0b0'. Pre-release separators must be normalized.
解决方案
-
98% 成功率
version='1.0.0b0' # instead of '1.0.0-beta'
-
90% 成功率
pip install setuptools_scm && echo '[tool.setuptools_scm]' >> pyproject.toml
-
85% 成功率
python -c "from packaging.version import Version; Version('1.0.0-beta')"
无效尝试
常见但无效的做法:
-
90% 失败
Legacy setup.py still validates version via packaging.
-
95% 失败
The value is already a string; the problem is its content.