openSUSE / python-rpm-macros

Multi-Python, Single-Spec macros generator
Other
22 stars 20 forks source link

Support python-foo-py3 as multiflavor package name #158

Closed danigm closed 1 year ago

danigm commented 1 year ago

This PR adds the name format python-FOO-py3 as a valid package name to generate FOO python package with the %{python_subpackages} macro and includes a new macro %{name_without_py3_suffix} to be able to use the generic package name in the spec file without the suffix.

This is useful to have multiple packages in the same project that generates the same python subpackages, but for different python versions, without source package name collision and being able to keep almost the same .spec file. For example:

bnavigator commented 1 year ago

This prevents any PyPI package ending in -py%d+

https://pypi.org/search/?q=-py3

Granted these probably won't be packaged ever, but the next package necessary to be included might just be around the corner.

Why not just explicitly use %files -n python3-FOO and the same for %package and %description?

Or why not directly use python3-FOO as specfile name? I am not sure if the latter still works, but orginally the python_subpackages rewriter was written with the possibility in mind that a python3-FOO.rpm from a python3-FOO.spec would be included.

https://github.com/openSUSE/python-rpm-macros/blob/4432ed04f26f8572789f2b8d63cd4f8d1c45fafa/macros.lua#L56-L59

danigm commented 1 year ago

This prevents any PyPI package ending in -py%d+

The name collision is a big problem, so if we want to go ahead with this rename we should take a more rare suffix, not just -py3.

Or why not directly use python3-FOO as specfile name? I am not sure if the latter still works, but orginally the python_subpackages rewriter was written with the possibility in mind that a python3-FOO.rpm from a python3-FOO.spec would be included.

That was the first idea, but it'll require more work because Requires, Provides and other python-foo names used are not translated in subpackages if the package name is the same as the pythons, so it cannot be just a package rename, it'll requires to review all references to python- in the spec file, something that's done automatically by the python_subpackages macro.

bnavigator commented 1 year ago

Replace all python- with python3- or whatever prefix you are using in the specfile name and it should translate all Requires, Provides etc. %python_subpackages stays in effect. You can even have multiple flavors in both specs.

danigm commented 1 year ago

Maybe this is not a good idea at all, thinking about it and after @bnavigator comments and clarifications, I think that it's okay to just rename to python3- and translate all Requires, Provides, etc.