Blob Blame Raw
# Python 3 only for Fedora for now.
%if 0%{?fedora} > 12
%global with_python3 1
%endif

# EPEL 6 compat stuff, per https://fedoraproject.org/wiki/EPEL:Packaging
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?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}}}

%global github_owner    mwclient
%global github_name     mwclient
%global github_commit   3f5898345059985e9f331ae16bf9f5d6d86edf80

Name:           python-mwclient
Version:        0.8.1
Release:        2%{?dist}
Summary:        Mwclient is a client to the MediaWiki API

Group:          System Environment/Libraries
License:        MIT
URL:            https://github.com/%{github_owner}/%{github_name}
Source0:        https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{github_name}-%{version}.tar.gz
# https://github.com/mwclient/mwclient/pull/107
# Fixes a py3-incompatible invocation of exec
Patch0:         0001-use-exec-in-py3-compatible-manner.patch
BuildArch:      noarch

BuildRequires:  python2-devel
# For EPEL
BuildRequires:  python-setuptools
# For tests, python-responses only available for Fedora >= 23
%if 0%{?fedora} > 22
BuildRequires:  python2-pytest
# Provides: python2-pytest-pep8 missing
BuildRequires:  python-pytest-pep8
# Provides: python2-pytest-cache missing on < F24
BuildRequires:  python-pytest-cache
# Provides: python2-pytest-cov missing on < F24
BuildRequires:  python-pytest-cov
# Provides: python2-mock missing on < F24
BuildRequires:  python-mock
BuildRequires:  python2-funcsigs
BuildRequires:  python2-responses >= 0.3.0
%endif # if fedora > 22
%if 0%{?with_python3}
BuildRequires:  python3-devel
%if 0%{?fedora} > 22
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-pep8
BuildRequires:  python3-pytest-cache
BuildRequires:  python3-pytest-cov
BuildRequires:  python3-mock
BuildRequires:  python3-funcsigs
BuildRequires:  python3-responses >= 0.3.0
%endif # if fedora > 22
%endif # if with_python3

%description
mwclient is a lightweight Python client library to the MediaWiki API which
provides access to most API functionality.

%package -n python2-%{github_name}
Summary:        %{summary}
%{?python_provide:%python_provide python2-%{github_name}}
# EPEL 6 compat, no python_provide there
%if 0%{?rhel}
%if %{rhel} < 7
Provides:       python-%{github_name} = %{version}-%{release}
Obsoletes:      python-%{github_name} < %{version}-%{release}
%endif # if rhel < 7
%endif # if rhel

Requires:       python-simplejson
# EL6/7 packages don't provide python2-requests
Requires:       python-requests

%description -n python2-%{github_name}
%{github_name} is a lightweight Python client library to the MediaWiki API which
provides access to most API functionality. This is the Python 2 build of
%{github_name}.

%if 0%{?with_python3}
%package -n python3-%{github_name}
Summary:        %{summary}
%{?python_provide:%python_provide python3-%{github_name}}
Requires:       python3-simplejson
Requires:       python3-requests

%description -n python3-%{github_name}
%{github_name} is a lightweight Python client library to the MediaWiki API which
provides access to most API functionality. This is the Python 3 build of
%{github_name}.
%endif # if with_python3

%prep
# autosetup isn't available on epel6 yet
%setup -q -n %{github_name}-%{github_commit}
%patch0 -p1 -b .execpy3


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


%install
%py2_install
%if 0%{?with_python3}
%py3_install
%endif # if with_python3


%check
%if 0%{?fedora} > 22
%{__python2} setup.py test
%if 0%{?with_python3}
%{__python3} setup.py test
%endif # if with_python3
%endif # if fedora > 22


%files -n python2-%{github_name}
%doc README.rst REFERENCE.md RELEASE-NOTES.md
%license LICENSE.md
%{python2_sitelib}/%{github_name}*

%if 0%{?with_python3}
%files -n python3-%{github_name}
%doc README.rst REFERENCE.md RELEASE-NOTES.md
%license LICENSE.md
%{python3_sitelib}/%{github_name}*
%endif # if with_python3


%changelog
- enable tests on F23 (python-funcsigs update went stable)

* Mon Feb 29 2016 Adam Williamson <awilliam@redhat.com> - 0.8.1-2
- re-add a patch which it turns out wasn't merged upstream yet

* Mon Feb 29 2016 Adam Williamson <awilliam@redhat.com> - 0.8.1-1
- new release 0.8.1
- drop patches merged upstream

* Tue Feb 16 2016 Adam Williamson <awilliam@redhat.com> - 0.8.0-3
- enable tests on Fedora > 23 (deps now available)

* Wed Feb 03 2016 Adam Williamson <awilliam@redhat.com> - 0.8.0-2
- fix an iterator problem with Python 3 (upstream PR #108)

* Thu Jan 21 2016 Adam Williamson <awilliam@redhat.com> - 0.8.0-1
- new release 0.8.0
- split into python2 and python3 builds (0.8.0 adds py3 support)

* Fri Aug 07 2015 Adam Williamson <awilliam@redhat.com> - 0.7.2-1
- new release 0.7.2

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Fri Dec 12 2014 Adam Williamson <awilliam@redhat.com> - 0.7.1-1
- new release 0.7.1, bit of spec cleaning

* Fri Oct 31 2014 Adam Williamson <awilliam@redhat.com> - 0.7.0-2
- requires python-requests

* Wed Oct 01 2014 Adam Williamson <awilliam@redhat.com> - 0.7.0-1
- new release: 0.7.0
- update for github source, use of setuptools and modern Python packaging rules

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Thu Oct 27 2011 Robert Scheck <robert@fedoraproject.org> - 0.6.5-1
- Upgrade to 0.6.5 (#714302)

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 0.6.3-4
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Tue Sep 22 2009 Steven M. Parrish <smparrish@gmail.com> - 0.6.3-3
- Fix patch

* Sun Sep 20 2009 Rex Dieter <rdieter@fedoraproject.org> - 0.6.3-2
- upstream wmf patch
- %%doc README.txt
- use %%global (instead of %%define)

* Tue Sep 15 2009  Steven M. Parrish <smparrish@gmail.com> - 0.6.3-1
- Initial build