Blob Blame History Raw
%global srcname winrm
%global sum Python libraries for interacting with windows remote management
%global gh_owner diyan
%global pypi_name py%{srcname}

%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.2.2
Release:        1%{?dist}
Summary:        %{sum}

License:        MIT
URL:            https://pypi.python.org/pypi/%{pypi_name}
Source0:        https://github.com/%{gh_owner}/%{pypi_name}/archive/v%{version}.tar.gz#/%{pypi_name}-%{version}.tar.gz
BuildArch:      noarch

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

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

%if 0%{?with_python3}
BuildRequires: python3-six
BuildRequires: python3-requests
BuildRequires: python3-xmltodict
BuildRequires: python3-pytest
BuildRequires: python3-mock
BuildRequires: python3-requests_ntlm
%endif

%description
This has the python libraries for interacting with Windows Remote Management

%package -n python2-%{srcname}
Summary:        %{sum}
%if 0%{?fedora}
Requires: python2-xmltodict
BuildRequires: python2-requests
%else
Requires: python-xmltodict
Requires: python-requests
%endif
Requires: python2-requests_ntlm
%{?python_provide:%python_provide python2-%{srcname}}

%description -n python2-%{srcname}
This has the python libraries for interacting with Windows Remote Management


%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary:        %{sum}
Requires: python3-xmltodict
Requires: python3-requests_ntlm
Requires: python3-requests
%{?python_provide:%python_provide python3-%{srcname}}

%description -n python3-%{srcname}
This has the python libraries for interacting with Windows Remote Management
%endif


%prep
%autosetup -n %{pypi_name}-%{version}

%build
%py2_build
%if 0%{?with_python3}
%py3_build
%endif

%install
# Must do the python2 install first because the scripts in /usr/bin are
# overwritten with every setup.py install, and in general we want the
# python3 version to be the default.
%py2_install
%if 0%{?with_python3}
%py3_install
%endif

%check
%{__python2} -m pytest winrm/tests
%if 0%{?with_python3}
%{__python3} -m pytest winrm/tests
%endif

# Note that there is no %%files section for the unversioned python module if we are building for several python runtimes
%files -n python2-%{srcname}
%license LICENSE
%doc README.md CHANGELOG.md
%{python2_sitelib}/*

%if 0%{?with_python3}
%files -n python3-%{srcname}
%license LICENSE
%doc README.md CHANGELOG.md
%{python3_sitelib}/*
%endif

%changelog
* Sat Feb 04 2017 James Hogarth <james.hogarth@gmail.com> - 0.2.2-1
- Update to 0.2.2
- Update requires to fix bz#1409670

* Tue Dec 20 2016 James Hogarth <james.hogarth@gmail.com> - 0.2.1-3
- Fix broken requires for epel

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

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