-1

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?

Darkdragon84
  • 539
  • 5
  • 13

1 Answers1

1

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

Clasherkasten
  • 488
  • 3
  • 9
  • AH, I should've known to look in the docs for wheel :'-) thanks for the swift reply! Can I limit the wheel to 3.10? Or do I just push a 3.11 release to the pypi registry which then gets used instead for py>=3.11? – Darkdragon84 Jun 29 '23 at 12:33
  • 1
    As of right now, I don't know any way to limit it over the python tag. However you could add `<3.11.0` to the `requires-python` and it would limit the package fully to 3.10. If you need a package for >=3.11, you would need to push a separate wheel to the registry. – Clasherkasten Jun 29 '23 at 13:11
  • right, yeah I have `requires-python = "==3.10.*"` there. It's just a shame you have to put this separately in two places in the toml. – Darkdragon84 Jul 03 '23 at 10:40