#2 Don't build Python 2 subpackage on EL > 7
Merged a year ago by crobinso. Opened a year ago by torsava.
rpms/ torsava/python-bugzilla master  into  master

file modified
+48 -12

@@ -1,13 +1,22 @@ 

- %if 0%{?fedora} || 0%{?rhel} >= 8

- %global with_python3 1

+ %if 0%{?fedora} || 0%{?rhel} > 7

+ # Enable python3 by default

+ %bcond_without python3

  %else

+ %bcond_with python3

+ %endif

+ 

+ %if 0%{?rhel} > 7

+ # Disable python2 build by default

+ %bcond_with python2

+ %else

+ %bcond_without python2

  %{!?__python2: %global __python2 /usr/bin/python2}

- %{!?python2_sitelib2: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}

+ %{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}

  %endif

  

  Name:           python-bugzilla

  Version:        2.1.0

- Release:        5%{?dist}

+ Release:        6%{?dist}

  Summary:        Python library for interacting with Bugzilla

  

  License:        GPLv2+

@@ -15,14 +24,16 @@ 

  Source0:        https://github.com/python-bugzilla/python-bugzilla/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz

  BuildArch:      noarch

  

+ %if %{with python2}

  BuildRequires: python2-devel

  BuildRequires: python2-requests

  BuildRequires: python2-setuptools

  %if 0%{?el6}

  BuildRequires: python-argparse

  %endif

+ %endif # with python2

  

- %if 0%{?with_python3}

+ %if %{with python3}

  BuildRequires: python3-devel

  BuildRequires: python3-requests

  BuildRequires: python3-setuptools

@@ -34,6 +45,8 @@ 

  

  %description %_description

  

+ 

+ %if %{with python2}

  %package -n python2-bugzilla

  Summary: %summary

  Requires: python2-requests

@@ -48,20 +61,28 @@ 

  

  %description -n python2-bugzilla %_description

  

- %if 0%{?with_python3}

+ %endif # with python2

+ 

+ 

+ %if %{with python3}

  %package -n python3-bugzilla

  Summary: %summary

  Requires: python3-requests

  Requires: python3-magic

  %{?python_provide:%python_provide python3-bugzilla}

  

+ %if %{without python2}

+ Obsoletes:      python-bugzilla < %{version}-%{release}

+ Obsoletes:      python2-bugzilla < %{version}-%{release}

+ %endif # without python2

+ 

  %description -n python3-bugzilla %_description

  %endif # if with_python3

  

  

  %package cli

  Summary: Command line tool for interacting with Bugzilla

- %if 0%{?with_python3}

+ %if %{with python3}

  Requires: python3-bugzilla = %{version}-%{release}

  %else

  Requires: python2-bugzilla = %{version}-%{release}

@@ -75,7 +96,7 @@ 

  %prep

  %setup -q

  

- %if 0%{?with_python3}

+ %if %{with python3}

  rm -rf %{py3dir}

  cp -a . %{py3dir}

  %endif # with_python3

@@ -83,30 +104,38 @@ 

  

  

  %build

- %if 0%{?with_python3}

+ %if %{with python3}

  pushd %{py3dir}

  %{__python3} setup.py build

  popd

  %endif # with_python3

  

+ %if %{with python2}

  %{__python2} setup.py build

+ %endif # with python2

  

  

  

  %install

- %if 0%{?with_python3}

+ %if %{with python3}

  pushd %{py3dir}

  %{__python3} setup.py install -O1 --skip-build --root %{buildroot}

+ 

+ %if %{with python2}

  rm %{buildroot}/usr/bin/bugzilla

+ %endif

+ 

  popd

  %endif # with_python3

  

+ %if %{with python2}

  %{__python2} setup.py install -O1 --skip-build --root %{buildroot}

+ %endif # with python2

  

  # Replace '#!/usr/bin/env python' with '#!/usr/bin/python2'

  # The format is ideal for upstream, but not a distro. See:

  # https://fedoraproject.org/wiki/Features/SystemPythonExecutablesUseSystemPython

- %if 0%{?with_python3}

+ %if %{with python3}

  %global python_env_path %{__python3}

  %else

  %global python_env_path %{__python2}

@@ -118,15 +147,19 @@ 

  

  

  %check

+ %if %{with python2}

  %{__python2} setup.py test

+ %endif # with python2

  

  

  

+ %if %{with python2}

  %files -n python2-bugzilla

  %doc COPYING README.md NEWS.md

  %{python2_sitelib}/*

+ %endif # with python2

  

- %if 0%{?with_python3}

+ %if %{with python3}

  %files -n python3-bugzilla

  %doc COPYING README.md NEWS.md

  %{python3_sitelib}/*

@@ -138,6 +171,9 @@ 

  

  

  %changelog

+ * Fri Mar 16 2018 Tomas Orsava <torsava@redhat.com> - 2.1.0-6

+ - Conditionalize the Python 2 subpackage

+ 

  * Fri Mar 09 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.1.0-5

  - Update Python 2 dependency declarations to new packaging standards

    (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

Conditionalize the Python 2 subpackage and don't build it on EL > 7.

I've also updated the Python 3 conditionals to bconds so they are uniform with Python 2. Bconds have the advantage of being able to be configured from the command line, modulemd file, etc.

rebased onto 49fa521

a year ago

Thanks for the patch. Is the idea that even EPEL packages shouldn't be building/distributing python2 stuff on RHEL8?

Yes. If this is is built on some newer version of RHEL (any larger than 7), python2 stuff is not supposed to be there.

rebased onto 5101108

a year ago

I've rebased the PR so it can be merged again.

Pull-Request has been merged by crobinso

a year ago