Hi, Am 27.04.21 um 20:00 schrieb Sean Marlow:
Hi,
I'm working on updating a python package that still has python2 support [1][2]. It has a dependency that's only required for python2 (enum34). Since the changes to allow multi-python in Tumbleweed were made I'm not sure how we should handle this type of scenario as it doesn't seeem documentation has been amended (or I'm looking in the wrong place). Can someone please confirm if I'm doing this correctly?
Nothing changed for python2 since the introduction of python3 multiflavor. If you think [3],[4] and [5] can be improved in this regard, please make suggestions. From your specfile:
%if 0%{?suse_version} >= 1500 %define skip_python2 1 %endif
So do you want to skip python2 for Leap 15.x (suse_version = 1500) but not for older distributions? You do not need to define skip_python2 for Tumbleweed. It's disabled by default.
%if %{?python_version_nodots} < 28 BuildRequires: %{python_module enum34} %endif
This won't work, because BuildRequires needs to be evaluated by the server and rpmbuild before starting to build, not by rpm __after__ the subpackage generation of %python_subpackages. (See my explanation to the factory list on Apr 19.) Use this instead: %bcond_without python2 %if %{with python2} BuildRequires: python2-enum34 %endif %ifpython2 Requires: python2-enum34 %endif Tumbleweed already specifies the necessary 'without python2' through its prjconf. Note that this is exactly what python-flask-restplus in your repo is doing already. If you want to skip for Leap 15.x consistent with your skip definition above, add: %if 0%{?suse_version} >= 1500 %define skip_python2 1 %bcond_with python2 %else %bcond_without python2 %endif There is also a shorter method for BuildRequires, which doesn't need any of the skips and bconds. But it requires a recent python-rpm-macros package and support for the %python pseudo-macro in the prjconf for all distribution targets: BuildRequires: %{python_module enum34 if (%python-base with python-base)} %ifpython2 Requires: python-enum34 %endif
Also, this package is a fork of flask-restplus which is no longer maintained. So I added a conflicts clause which as far as I could tell was the proper way to handle this. Since the packages conflict on namespace they should be mutually exclusive.
[1] https://build.opensuse.org/package/view_file/home:seanmarlow:branches:devel:... [2] https://build.opensuse.org/package/rdiff/home:seanmarlow:branches:devel:languages:python:flask/python-flask-restx?opackage=python-flask-restx&oproject=devel%3Alanguages%3Apython%3Aflask&rev=7
Thanks, Sean
Cheers, Ben [3] https://en.opensuse.org/openSUSE:Packaging_Python#BuildRequires [4] https://en.opensuse.org/openSUSE:Packaging_Python#Requirements_specific_for_... [5] https://github.com/openSUSE/python-rpm-macros#readme