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:        1.1.0
Release:        1%{?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/v%{version}.tar.gz#/%{gh_name}-%{version}.tar.gz
BuildArch:      noarch

BuildRequires:  python2-setuptools
BuildRequires:  python2-devel
BuildRequires:  python2-ntlm-auth
BuildRequires:  python2-cryptography

%if 0%{?with_python3}
BuildRequires:  python3-setuptools
BuildRequires:  python3-devel
BuildRequires:  python3-ntlm-auth
%endif

# For tests
%if 0%{?fedora}
BuildRequires:  python2-pytest
BuildRequires:  python2-requests
BuildRequires:  python2-flask
%else
BuildRequires:  pytest
BuildRequires:  python-requests
BuildRequires:  python-flask
%endif
%if 0%{?rhel} && 0%{?rhel} <= 6
BuildRequires:  python-jinja2
%endif

%if 0%{?with_python3}
BuildRequires:  python3-pytest
BuildRequires:  python3-requests
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}
Requires:       python2-cryptography
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}
Requires:       python3-cryptography
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
%{__python2} -m tests.test_server &
%{__python2} -m pytest --ignore=tests/functional/test_functional.py --ignore=tests/test_server.py tests
pkill -f 'python2 -m tests.test_server'
%if 0%{?with_python3}
%{__python3} -m tests.test_server &
%{__python3} -m pytest --ignore=tests/functional/test_functional.py --ignore=tests/test_server.py tests
pkill -f 'python3 -m tests.test_server'
%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
* Tue Apr 17 2018 James Hogarth <james.hogarth@gmail.com> - 1.1.0-1
- Upstream release 1.1.0

* Wed Feb 28 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.3.0-6
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* 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.