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

Some SPEC file modernizations.
epel8
Charalampos Stratakis 7 years ago
parent 23ddc4783c
commit 89cc12b61d

@ -1,11 +1,15 @@
%if 0%{?fedora}
%global with_python3 1
%if 0%{?fedora} || 0%{?rhel} > 7
# Enable python3 build by default
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%if 0%{?rhel} > 7
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
%global modname freezegun
@ -13,7 +17,7 @@
Name: python-freezegun
Version: 0.3.8
Release: 8%{?dist}
Release: 9%{?dist}
Summary: %{sum}
Group: Development/Libraries
@ -23,6 +27,13 @@ Source0: https://pypi.io/packages/source/f/%{modname}/%{modname}-%{ve
BuildArch: noarch
%description
freezegun is a library that allows your python tests to travel through time by
mocking the datetime module.
%if %{with python2}
%package -n python2-freezegun
Summary: %{sum}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
@ -33,40 +44,29 @@ BuildRequires: python2-nose
BuildRequires: python2-coverage
BuildRequires: python2-mock
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-six
BuildRequires: python3-dateutil
BuildRequires: python3-sure
BuildRequires: python3-nose
BuildRequires: python3-coverage
BuildRequires: python3-mock
%endif
%description
freezegun is a library that allows your python tests to travel through time by
mocking the datetime module.
%package -n python2-freezegun
Summary: %{sum}
Group: Development/Libraries
%{?python_provide:%python_provide python2-freezegun}
# EL packages don't provide python2-foo
Requires: python2-six
Requires: python2-dateutil
%description -n python2-freezegun
freezegun is a library that allows your python tests to travel through time by
mocking the datetime module. This is the Python 2 library.
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
%package -n python3-freezegun
Summary: %{sum}
Group: Development/Libraries
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-six
BuildRequires: python3-dateutil
BuildRequires: python3-sure
BuildRequires: python3-nose
BuildRequires: python3-coverage
BuildRequires: python3-mock
%{?python_provide:%python_provide python3-freezegun}
Requires: python3-six
@ -75,56 +75,67 @@ Requires: python3-dateutil
%description -n python3-freezegun
freezegun is a library that allows your python tests to travel through time by
mocking the datetime module. This is the Python 3 library.
%endif
%endif # with python3
%prep
%setup -q -n %{modname}-%{version}
# Remove bundled egg-info in case it exists
rm -rf %{modname}.egg-info
%if 0%{?with_python3}
%if %{with python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif
%endif # with python3
%build
%{__python2} setup.py build
%if 0%{?with_python3}
%if %{with python2}
%py2_build
%endif # with python2
%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py build
%py3_build
popd
%endif
%endif # with python3
%install
%if 0%{?with_python3}
%if %{with python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root=%{buildroot}
%py3_install
popd
%endif
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
%endif # with python3
%if %{with python2}
%py2_install
%endif # with python2
%check
%if %with python3
%if %{with python3}
pushd %{py3dir}
nosetests-%{python3_version} tests/
popd
%endif
%endif # with python3
%if %{with python2}
nosetests-%{python2_version} tests/
%endif # with python2
%if %{with python2}
%files -n python2-freezegun
%doc README.rst LICENSE
%{python2_sitelib}/%{modname}/
%{python2_sitelib}/%{modname}-%{version}*
%endif # with python2
%if 0%{?with_python3}
%if %{with python3}
%files -n python3-freezegun
%doc README.rst LICENSE
%{python3_sitelib}/%{modname}/
%{python3_sitelib}/%{modname}-%{version}-*
%endif
%endif # with python3
%changelog
* Thu Apr 05 2018 Charalampos Stratakis <cstratak@redhat.com> - 0.3.8-9
- Conditionalize the Python 2 subpackage and don't build it on EL > 7
* Wed Feb 21 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.3.8-8
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

Loading…
Cancel
Save