Add with_python3 guards

It's been requested to build against epel7 which does not have python3.
I'd prefer to deal with the if statements than have different specs
between fedora and EPEL.
This commit is contained in:
Jamie Lennox 2015-02-25 11:01:39 +11:00
parent 2e8183c723
commit aa1b17497b

View File

@ -1,8 +1,13 @@
%if 0%{?fedora}
# escaping for EPEL.
%global with_python3 0
%endif
%global run_tests 0 %global run_tests 0
Name: python-httpretty Name: python-httpretty
Version: 0.8.3 Version: 0.8.3
Release: 1%{?dist} Release: 2%{?dist}
Summary: HTTP request mock tool for Python Summary: HTTP request mock tool for Python
License: MIT License: MIT
@ -32,6 +37,7 @@ what if the API server is down? What if its content has changed?
Don't worry, HTTPretty is here for you. Don't worry, HTTPretty is here for you.
%if 0%{?with_python3}
%package -n python3-httpretty %package -n python3-httpretty
Summary: HTTP request mock tool for Python 3 Summary: HTTP request mock tool for Python 3
Requires: python3-urllib3 Requires: python3-urllib3
@ -45,29 +51,36 @@ fine but until the day he needed to test the code that hits the RESTful API:
what if the API server is down? What if its content has changed? what if the API server is down? What if its content has changed?
Don't worry, HTTPretty is here for you. Don't worry, HTTPretty is here for you.
%endif
%prep %prep
%setup -q -n httpretty-%{version} %setup -q -n httpretty-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%if 0%{?with_python3}
rm -rf %{py3dir} rm -rf %{py3dir}
cp -a . %{py3dir} cp -a . %{py3dir}
%endif
%build %build
CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build
%if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
popd popd
%endif
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
%if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
popd popd
%endif
%check %check
@ -77,10 +90,12 @@ popd
%if %{run_tests} %if %{run_tests}
%{__python2} setup.py test %{__python2} setup.py test
%if 0%{?with_python3}
pushd %{py3dir} pushd %{py3dir}
%{__python3} setup.py test %{__python3} setup.py test
popd popd
%endif %endif
%endif
%files %files
@ -88,13 +103,18 @@ popd
%{python_sitelib}/httpretty %{python_sitelib}/httpretty
%{python_sitelib}/httpretty-%{version}-py2.?.egg-info %{python_sitelib}/httpretty-%{version}-py2.?.egg-info
%if 0%{?with_python3}
%files -n python3-httpretty %files -n python3-httpretty
%doc COPYING README.md %doc COPYING README.md
%{python3_sitelib}/httpretty %{python3_sitelib}/httpretty
%{python3_sitelib}/httpretty-%{version}-py3.?.egg-info %{python3_sitelib}/httpretty-%{version}-py3.?.egg-info
%endif
%changelog %changelog
* Tue Feb 24 2015 Jamie Lennox <jamielennox@redhat.com> - 0.8.3-2
- Added with_python3 build flags to enable building on EPEL.
* Mon Jul 28 2014 Jamie Lennox <jamielennox@redhat.com> - 0.8.3-1 * Mon Jul 28 2014 Jamie Lennox <jamielennox@redhat.com> - 0.8.3-1
- Updated to new version. - Updated to new version.
- Removed check, there are simply too many problems upstream. - Removed check, there are simply too many problems upstream.