diff --git a/python-requests_ntlm.spec b/python-requests_ntlm.spec index 50f1013..86677fe 100644 --- a/python-requests_ntlm.spec +++ b/python-requests_ntlm.spec @@ -2,6 +2,19 @@ %global gh_owner requests %global gh_name requests-ntlm +%if 0%{?fedora} +# escaping for EPEL. +%global with_python3 1 +%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))")} +%{!?py2_build: %global py2_build %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} build --executable="%{__python2} -s"}} +%{!?py2_install: %global py2_install %{expand: CFLAGS="%{optflags}" %{__python2} setup.py %{?py_setup_args} install -O1 --skip-build --root %{buildroot}}} +%endif + Name: python-%{srcname} Version: 0.3.0 Release: 1%{?dist} @@ -15,18 +28,31 @@ BuildArch: noarch BuildRequires: python-setuptools BuildRequires: python2-devel +%if 0%{?with_python3} BuildRequires: python3-setuptools BuildRequires: python3-devel +%endif # For tests +%if 0%{?fedora} BuildRequires: python2-pytest -BuildRequires: python3-pytest BuildRequires: python2-requests -BuildRequires: python3-requests +%else +BuildRequires: pytest +BuildRequires: python-requests +%endif BuildRequires: python2-ntlm3 -BuildRequires: python3-ntlm3 BuildRequires: python-flask +%if 0%{?rhel} && 0%{?rhel} <= 6 +BuildRequires: python-jinja2 +%endif + +%if 0%{?with_python3} +BuildRequires: python3-pytest +BuildRequires: python3-requests +BuildRequires: python3-ntlm3 BuildRequires: python3-flask +%endif BuildRequires: /usr/bin/pkill %description @@ -42,6 +68,7 @@ Requires: python2-ntlm3 This package allows Python clients running on any operating system to provide NTLM authentication to a supporting server. +%if 0%{?with_python3} %package -n python3-%{srcname} Summary: Python 3 compatible NTLM library %{?python_provide:%python_provide python3-%{srcname}} @@ -50,6 +77,7 @@ Requires: python3-ntlm3 %description -n python3-%{srcname} This package allows Python clients running on any operating system to provide NTLM authentication to a supporting server. +%endif %prep %autosetup -n %{gh_name}-%{version} @@ -58,22 +86,32 @@ rm -rf %{srcname}.egg-info %build %py2_build +%if 0%{?with_python3} %py3_build +%endif %install # Must do the subpackages' install first because the scripts in /usr/bin are # overwritten with every setup.py install. +%if 0%{?with_python3} %py3_install +%endif %py2_install %check %{__python} tests/test_server.py & +%if 0%{?rhel} && 0%{?rhel} <= 6 +%{__python} -m pytest --assert=reinterp tests/test_requests_ntlm.py +%else %{__python} -m pytest tests/test_requests_ntlm.py +%endif pkill -f test_server.py +%if 0%{?with_python3} %{__python3} tests/test_server.py & %{__python3} -m pytest tests/test_requests_ntlm.py pkill -f test_server.py +%endif %files -n python2-%{srcname} %license LICENSE @@ -81,11 +119,13 @@ pkill -f test_server.py %{python2_sitelib}/%{srcname} %{python2_sitelib}/%{srcname}-%{version}-py?.?.egg-info +%if 0%{?with_python3} %files -n python3-%{srcname} %license LICENSE %doc CONTRIBUTORS.rst README.rst %{python3_sitelib}/%{srcname} %{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info +%endif %changelog * Mon Oct 10 2016 James Hogarth - 0.3.0-1