Blob Blame History Raw
%global srcname requests_ntlm
%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:        4%{?dist}
Summary:        NTLM module for python requests

License:        ISC
URL:            https://pypi.python.org/pypi/%{srcname}
Source0:        https://github.com/%{gh_owner}/%{gh_name}/archive/%{version}.tar.gz#/%{gh_name}-%{version}.tar.gz
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:  python2-requests
%else
BuildRequires:  pytest
BuildRequires:  python-requests
%endif
BuildRequires:  python2-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
 This package allows Python clients running on any operating system to provide
NTLM authentication to a supporting server.

%package -n     python2-%{srcname}
Summary:        Python 3 compatible NTLM library
%{?python_provide:%python_provide python2-%{srcname}}
Requires:       python2-ntlm3

%description -n python2-%{srcname}
 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}}
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}
# Remove bundled egg-info
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
%doc CONTRIBUTORS.rst README.rst
%{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
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Dec 19 2016 Miro HronĨok <mhroncok@redhat.com> - 0.3.0-2
- Rebuild for Python 3.6

* Mon Oct 10 2016 James Hogarth <james.hogarth@gmail.com> - 0.3.0-1
- Initial package.