twine upload dist/* 遇到下面的问题
Uploading distributions to https://upload.pypi.org/legacy/
ERROR InvalidDistribution: Metadata is missing required fields: Name, Version.
Make sure the distribution includes the files where those fields are specified, and is using a supported Metadata-Version: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2.
环境:
- 使用 pyproject.toml 配置包信息
- 使用 python -m build 打包
错误信息分析
问题是没有指定包的 Name 和 version,但是 toml 文件中已经指定了。所以是 metadata 的版本不支持。查看打包出来的 PKG-INFO 会发现, metadata 是 2.3
https://github.com/pypa/packaging-problems/issues/735#issuecomment-2002497285
这里有说明是应为 pip 升级导致打包出来 2.3 的 metadata,此时需要升级 pkginfo ,twine 才能正常上传
pip install pkginfo==1.10.0
升级后,可以正常上传