Don't build Python 2 subpackage on EL > 7

This commit is contained in:
Charalampos Stratakis 2018-03-15 18:25:42 +01:00
parent 760285efc4
commit d9fcc4b666

View File

@ -1,11 +1,22 @@
%global pypi_name jsonpatch
%if 0%{?fedora} || 0%{?rhel} > 7
%global with_python3 1
# Enable python3 build 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
%endif
Name: python-%{pypi_name}
Version: 1.21
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Applying JSON Patches in Python
License: BSD
@ -20,6 +31,7 @@ BuildArch: noarch
%description
Library to apply JSON Patches according to RFC 6902 - Python 2 build.
%if %{with python2}
%package -n python2-%{pypi_name}
Summary: Applying JSON Patches in Python 2
@ -32,9 +44,9 @@ Requires: python2-jsonpointer
%description -n python2-%{pypi_name}
Library to apply JSON Patches according to RFC 6902 - Python 2 build.
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
%package -n python3-%{pypi_name}
Summary: Applying JSON Patches in Python 3
@ -47,7 +59,7 @@ Requires: python3-jsonpointer
%description -n python3-%{pypi_name}
Library to apply JSON Patches according to RFC 6902 - Python 3 build.
%endif
%endif # with python3
%prep
%setup -qn %{pypi_name}-%{version}
@ -55,13 +67,16 @@ Library to apply JSON Patches according to RFC 6902 - Python 3 build.
%build
%if %{with python2}
%py2_build
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
LANG=en_US.utf8 %py3_build
%endif
%endif # with python3
%install
%if %{with python2}
%py2_install
for bin in jsondiff jsonpatch; do
mv %{buildroot}%{_bindir}/$bin %{buildroot}%{_bindir}/$bin-%{python2_version}
@ -70,23 +85,27 @@ ln -s ./$bin-%{python2_version} %{buildroot}%{_bindir}/$bin-2
ln -s ./$bin-%{python2_version} %{buildroot}%{_bindir}/$bin
%endif
done;
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
LANG=en_US.utf8 %py3_install
for bin in jsondiff jsonpatch; do
mv %{buildroot}%{_bindir}/$bin %{buildroot}%{_bindir}/$bin-%{python3_version}
ln -s ./$bin-%{python3_version} %{buildroot}%{_bindir}/$bin-3
ln -s ./$bin-%{python3_version} %{buildroot}%{_bindir}/$bin
done;
%endif
%endif # with python3
%check
%if %{with python2}
%{__python2} tests.py
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
%{__python3} tests.py
%endif
%endif # with python3
%if %{with python2}
%files -n python2-%{pypi_name}
%doc README.md
%license COPYING
@ -98,8 +117,9 @@ done;
%{_bindir}/jsonpatch-2*
%{python2_sitelib}/%{pypi_name}.py*
%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
%files -n python3-%{pypi_name}
%doc README.md
%license COPYING
@ -110,9 +130,12 @@ done;
%{python3_sitelib}/%{pypi_name}.py*
%{python3_sitelib}/__pycache__/*
%{python3_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif
%endif # with python3
%changelog
* Thu Mar 15 2018 Charalampos Stratakis <cstratak@redhat.com> - 1.21-2
- Don't build Python 2 subpackage on EL > 7
* Tue Feb 6 2018 Alfredo Moralejo <amoralej@redhat.com> - 1.21-1
- Update to 1.21