Blob Blame History Raw
%global srcname ntlm-auth
%global pypi_name %{srcname}
%global gh_owner jborean93
%global library_name ntlm_auth

%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:        2%{?dist}
Summary:        Python 3 compatible NTLM library

License:        LGPLv3+
URL:            https://pypi.python.org/pypi/%{pypi_name}
Source0:        https://github.com/%{gh_owner}/%{pypi_name}/archive/v%{version}.tar.gz#/%{srcname}-%{version}.tar.gz
Patch0:         ntlm-auth-epel-setuptools.patch
BuildArch:      noarch

BuildRequires:  python-setuptools
BuildRequires:  python2-devel

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

%if 0%{?rhel} && 0%{?rhel} <= 6
BuildRequires: python-ordereddict
%endif

# For tests
%if 0%{?fedora}
BuildRequires:  python2-pytest
BuildRequires:  python2-requests
%else
BuildRequires:  pytest
BuildRequires:  python-requests
%endif

%if 0%{?with_python3}
BuildRequires:  python3-pytest
BuildRequires:  python3-requests
%endif

%description
 This package allows Python clients running on any operating system to provide
NTLM authentication to a supporting server.

%package -n     python2-%{srcname}
Obsoletes:      python2-ntlm3 < 1.0.3-1
Provides:       python2-ntlm3 = %{version}-%{release}
Summary:        Python 3 compatible NTLM library
%{?python_provide:%python_provide python2-%{srcname}}

%if 0%{?rhel} && 0%{?rhel} <= 6
Requires: python-ordereddict
%endif
%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}
Obsoletes:      python3-ntlm3 < 1.0.3-1
Provides:       python3-ntlm3 = %{version}-%{release}
Summary:        Python 3 compatible NTLM library
%{?python_provide:%python_provide python3-%{srcname}}

%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 %{pypi_name}-%{version}

# Remove bundled egg-info
rm -rf %{pypi_name}.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
# Allow this to work with pytest in el6
%{__python2} -m pytest --ignore=tests/functional/test_iis.py tests
%if 0%{?with_python3}
%{__python3} -m pytest --ignore=tests/functional/test_iis.py tests
%endif

%files -n python2-%{srcname}
%doc CHANGES.md README.md
%license LICENSE
%{python2_sitelib}/%{library_name}
%{python2_sitelib}/%{library_name}-%{version}-py?.?.egg-info

%if 0%{?with_python3}
%files -n python3-%{srcname}
%doc CHANGES.md README.md
%license LICENSE
%{python3_sitelib}/%{library_name}
%{python3_sitelib}/%{library_name}-%{version}-py?.?.egg-info
%endif

%changelog
* Tue Jun 19 2018 Miro HronĨok <mhroncok@redhat.com> - 1.1.0-2
- Rebuilt for Python 3.7

* Tue Apr 17 2018 James Hogarth <james.hogarth@gmail.com> = 1.1.0-1
* Upstream update to 1.1.0
* Mon Oct 10 2016 James Hogarth <james.hogarth@gmail.com> - 1.0.2-1
- Initial package.