#6 Conditionalize py2/py3 builds
Opened 4 years ago by xavierb. Modified 4 years ago
rpms/ xavierb/python-dulwich cond_py  into  rawhide

file modified
+46 -21
@@ -4,9 +4,16 @@ 

  %global __provides_exclude_from ^(%{python2_sitearch}/.*\\.so)$

  %global __provides_exclude_from ^(%{python3_sitearch}/.*\\.so)$

  

+ %if %{defined el6} || %{defined el7} || (0%{?fedora} && 0%{?fedora} < 31)

+ %bcond_without python2

+ %endif

+ 

+ %bcond_without python3

+ 

+ 

  Name:           python-%{srcname}

  Version:        0.19.11

- Release:        3%{?dist}

+ Release:        4%{?dist}

  Summary:        %{sum}

  

  License:        GPLv2+ or ASL 2.0
@@ -14,16 +21,7 @@ 

  Source0:        %pypi_source dulwich

  

  BuildRequires:  gcc

- BuildRequires:  python2-devel

- BuildRequires:  python3-devel

- BuildRequires:  python2-nose

- BuildRequires:  python2-docutils

- BuildRequires:  python3-sphinx

- BuildRequires:  python3-docutils

  

- %if (0%{?rhel} && 0%{?rhel} < 7) || (0%{?fedora} && 0%{?fedora} < 14)

- BuildRequires:  python-unittest2

- %endif

  

  %description

  Dulwich is a pure-Python implementation of the Git file formats and
@@ -36,8 +34,16 @@ 

  %description -n %{srcname}-core

  Files to ensure functionality for both python2 and python3 packages of Dulwich.

  

+ %if %{with python2}

  %package -n python2-%{srcname}

  Summary:        %{sum}

+ BuildRequires:  python2-devel

+ BuildRequires:  python2-docutils

+ BuildRequires:  python2-nose

+ BuildRequires:  python2-sphinx

+ %if (0%{?rhel} && 0%{?rhel} < 7) || (0%{?fedora} && 0%{?fedora} < 14)

+ BuildRequires:  python-unittest2

+ %endif

  %{?python_provide:%python_provide python2-%{srcname}}

  Requires:       %{srcname}-core%{?_isa} = %{version}-%{release}

  
@@ -45,16 +51,22 @@ 

  Dulwich is a pure-Python implementation of the Git file formats and

  protocols. The project is named after the village in which Mr. and

  Mrs. Git live in the Monty Python sketch.

+ %endif

  

- %package -n python3-%{srcname}

+ %if %{with python3}

+ %package -n python%{python3_pkgversion}-%{srcname}

  Summary:        %{sum}

- %{?python_provide:%python_provide python3-%{srcname}}

+ BuildRequires:  python%{python3_pkgversion}-devel

+ BuildRequires:  python%{python3_pkgversion}-docutils

+ BuildRequires:  python%{python3_pkgversion}-sphinx

+ %{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}

  Requires:       %{srcname}-core%{?_isa} = %{version}-%{release}

  

- %description -n python3-%{srcname}

+ %description -n python%{python3_pkgversion}-%{srcname}

  Dulwich is a pure-Python implementation of the Git file formats and

  protocols. The project is named after the village in which Mr. and

  Mrs. Git live in the Monty Python sketch.

+ %endif

  

  %prep

  %autosetup -n %{srcname}-%{version}
@@ -63,22 +75,27 @@ 

  sed -i '/sphinx_epytext/d' docs/conf.py

  

  %build

- %py2_build

- %py3_build

+ %{?with_python2:%py2_build}

+ %{?with_python3:%py3_build}

  pushd docs

+ %if 0%{?el6}%{?el7}

+ sed -i -e 's,sphinx-apidoc -feM,sphinx-apidoc -f,' Makefile

+ %endif

  # Not using {smp_flags} as sphinx fails with it from time to time

  make html

  rm -rf build/html/{.buildinfo,doctrees}

- sphinx-build-3 -b html -d py3/doctrees . py3/html

+ %if %{with python3}

+ sphinx-build-%{python3_version} -b html -d py3/doctrees . py3/html

  rm -rf py3/html/.buildinfo

+ %endif

  popd

  

  %install

- %py2_install

- %py3_install

+ %{?with_python2:%py2_install}

+ %{?with_python3:%py3_install}

  # Remove extra copy of text docs

- rm -rf %{buildroot}%{python2_sitearch}/docs/tutorial/

- rm -rf %{buildroot}%{python3_sitearch}/docs/tutorial/

+ %{?with_python2:rm -rf %{buildroot}%{python2_sitearch}/docs/tutorial/}

+ %{?with_python3:rm -rf %{buildroot}%{python3_sitearch}/docs/tutorial/}

  

  #%check

  # FIXME test_non_ascii fails cause of unicode issue
@@ -90,17 +107,25 @@ 

  %{_bindir}/dul-*

  %{_bindir}/%{srcname}

  

+ %if %{with python2}

  %files -n python2-%{srcname}

  %doc docs/build/html/

  %{python2_sitearch}/%{srcname}*

  %exclude %{python2_sitearch}/%{srcname}/tests*

+ %endif

  

- %files -n python3-%{srcname}

+ %if %{with python3}

+ %files -n python%{python3_pkgversion}-%{srcname}

  %doc docs/py3/html/

  %{python3_sitearch}/%{srcname}*

  %exclude %{python3_sitearch}/%{srcname}/tests*

+ %endif

  

  %changelog

+ * Tue Aug 13 2019 Xavier Bachelot <xavier@bachelot.org> - 0.19.11-4

+ - Conditionalize python2/python3 builds.

+ - Fix build on EL7.

+ 

  * Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.19.11-3

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

  

This PR conditionalizes py2 and py3 builds according to the distro/release. It does not change which flavors are builds, except for f31, which drops the py2 sub-package.
Also, fixes build on EPEL7 which changed from python3-foo to python36-foo. Again, this does not change on Fedora where the packages are still python2-foo and python3-foo.
A similar change was made in the f30 branch with commit https://src.fedoraproject.org/rpms/python-dulwich/c/e30e9610b34bd02643f25e771174652d1aba7fe6?branch=f30
This PR targets master and should be suitable for all branches.
Please review.

Metadata