Handling Python2 specific dependencies and multi-python
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? 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
On Tue, 2021-04-27 at 18:00 +0000, Sean Marlow wrote:
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?
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.
Sorry, I'm mixing up packages that I'm working on. The conflict issue is with a different package so I dropped it from here [3].
[1]
https://build.opensuse.org/package/view_file/home:seanmarlow:branches:devel:... [2]
Thanks, Sean
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
On Tue, 2021-04-27 at 20:46 +0200, Ben Greiner wrote: Hi Ben,
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.
Ah, right so only python3 is affected with multiflavor for Tumbleweed.
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?
I mainly wanted to avoid building for python2 for any newer distributions. The package still has python2 support though. Also, I wanted to ensure the package built for all supported distributions. The test_handle_non_api_error I skipped relies on a specific version of werkzeug which breaks non Tumbleweed builds. Even though the package itself has no reliance on a specific werkzeug version.
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
Ack, I've updated the spec based on this and it seems to work as expected.
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]
Thanks, Sean
Cheers, Ben
Thanks for the pointers.
[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
participants (2)
-
Ben Greiner
-
Sean Marlow