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

Loading…
Cancel
Save