Python内置轮子名称的次要版本

huangapple go评论67阅读模式
英文:

python minor version in built wheel name

问题

我正在尝试在使用pip wheel构建的wheel名称中包含Python的次要版本。我的项目基于pyproject.toml,该文件指定了版本号等信息,还通过requires-python要求一个具体的Python次要版本。

然而,在构建wheel时,结果文件的名称是my_package-1.0.0-py3-none-any.whl

我想要的是my_package-1.0.0-py310-none-any.whl。如何让pip包括次要版本?pyproject.toml中是否有一些设置?

(请注意,上面的回答是翻译,不包括问题,只有问题的翻译部分。)

英文:

I am trying to include the minor python version in the name of a wheel built with pip wheel. My project is based on a pyproject.toml that specifies version number etc. and also requires a concrete minor version of python via requires-python.

[build-system]
requires = ['setuptools']
build-backend = 'setuptools.build_meta'

[project]
version = '1.0.0'
name = 'my-package'

requires-python = '==3.10.*'

dependencies = [
  ...
]

However, when building the wheel

pip wheel --no-deps .

the resulting file's name is my_package-1.0.0-py3-none-any.whl.

What I would like however is my_package-1.0.0-py310-none-any.whl. How can I get pip to include the minor version? Is there some setting in pyproject.toml?

答案1

得分: 1

你可以在生成的 wheel 中手动指定使用的 Python 标签,方法如下:

[tool.distutils.bdist_wheel]
python-tag = "py310"
# ...

一个使用示例是 black 19.10b0对应的配置)(尽管它们在其 setup.cfg 中执行此操作)。

请注意,现在生成的 wheel 仍与更高版本的 Python 兼容(在本例中是 3.11、3.12 和 3.13,以及所有未来的版本)。

您可以在 wheel tags 文档 中详细了解此内容。

英文:

You can manually specify the python tag used in the generated wheel doing the following:

[tool.distutils.bdist_wheel]
python-tag = "py310"
# ...

An example for the usage of this is black 19.10b0 (corresponding config) (though they do it in their setup.cfg).

Note that the now generated wheel is still compatible with higher python versions (in this case 3.11, 3.12 and 3.13 as well as every future version).

You can read more about this in the wheel tags docs

huangapple
  • 本文由 发表于 2023年6月29日 18:13:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580097.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定