#
# Conditional build:
%bcond_without python2 # CPython 2.x module
-%bcond_without python3 # CPython 3.x module
+%bcond_with python3 # CPython 3.x module (built from python3-pygments.spec)
+%bcond_without doc # Sphinx documentation
+%bcond_without tests # unit tests
%define module pygments
Summary: A generic syntax highlighter as Python 2.x module
Summary(pl.UTF-8): Moduł Pythona 2.x do ogólnego podświetlania składni
Name: python-%{module}
-Version: 2.0.2
-Release: 1
+Version: 2.5.2
+Release: 4
License: BSD
Group: Development/Languages/Python
-Source0: http://pypi.python.org/packages/source/P/Pygments/Pygments-%{version}.tar.gz
-# Source0-md5: 238587a1370d62405edabd0794b3ec4a
-URL: http://pygments.org/
+#Source0Download: https://pypi.org/simple/pygments/
+Source0: https://files.pythonhosted.org/packages/source/P/Pygments/Pygments-%{version}.tar.gz
+# Source0-md5: 465a35559863089d959d783a69f79b9f
+Patch0: rpmspec.patch
+URL: https://pygments.org/
+BuildRequires: rpmbuild(macros) >= 1.714
%if %{with python2}
-BuildRequires: python
-BuildRequires: python-devel
-BuildRequires: python-modules
+BuildRequires: python >= 1:2.7
+BuildRequires: python-devel >= 1:2.7
+BuildRequires: python-modules >= 1:2.7
BuildRequires: python-setuptools
+%if %{with tests}
+BuildRequires: python-pytest
+%endif
%endif
%if %{with python3}
-BuildRequires: python3
-BuildRequires: python3-2to3
-BuildRequires: python3-devel
-BuildRequires: python3-modules
+BuildRequires: python3 >= 1:3.5
+BuildRequires: python3-devel >= 1:3.5
+BuildRequires: python3-modules >= 1:3.5
BuildRequires: python3-setuptools
+%if %{with tests}
+BuildRequires: python3-pytest
+%endif
%endif
BuildRequires: rpm-pythonprov
-Requires: python-modules
+%{?with_doc:BuildRequires: sphinx-pdg-2}
+Requires: python-modules >= 1:2.7
Requires: python-setuptools
Provides: python-Pygments = %{version}-%{release}
-Obsoletes: python-Pygments
+Obsoletes: python-Pygments < 1.5
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
Summary: Generic syntax highlighter as Python 3.x module
Summary(pl.UTF-8): Moduł Pythona 3.x do ogólnego podświetlania składni
Group: Development/Languages/Python
-Requires: python3-modules
+Requires: python3-modules >= 1:3.5
Requires: python3-setuptools
+Conflicts: python-pygments < 2.5.2
%description -n python3-%{module}
Pygments is a generic syntax highlighter for general use in all kinds
- możliwość używania z linii poleceń oraz jako biblioteki
- ...a także - podświetla nawet Brainf*cka!
+%package apidocs
+Summary: API documentation for Python Pygments module
+Summary(pl.UTF-8): Dokumentacja API modułu Pythona Pygments
+Group: Documentation
+
+%description apidocs
+API documentation for Python Pygments module.
+
+%description apidocs -l pl.UTF-8
+Dokumentacja API modułu Pythona Pygments.
+
%prep
%setup -q -n Pygments-%{version}
+%patch0 -p1
%build
%if %{with python2}
-%{__python} setup.py build -b build-2
+%py_build
+
+%if %{with tests}
+%{__python} -m pytest tests
+%endif
%endif
%if %{with python3}
-%{__python3} setup.py build -b build-3
+%py3_build
+
+%if %{with tests}
+%{__python3} -m pytest tests
+%endif
+%endif
+
+%if %{with doc}
+PYTHONPATH=$(pwd) \
+%{__make} -C doc html \
+ SPHINXBUILD=sphinx-build-2
%endif
%install
rm -rf $RPM_BUILD_ROOT
%if %{with python2}
-%{__python} setup.py \
- build -b build-2 \
- install \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
+%py_install
-mv $RPM_BUILD_ROOT%{_bindir}/pygmentize{,-2}
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/pygmentize{,-2}
-%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
-%py_comp $RPM_BUILD_ROOT%{py_sitedir}
%py_postclean
%endif
%if %{with python3}
-%{__python3} setup.py \
- build -b build-3 \
- install \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
+%py3_install
-mv $RPM_BUILD_ROOT%{_bindir}/pygmentize{,-3}
+%{__mv} $RPM_BUILD_ROOT%{_bindir}/pygmentize{,-3}
%endif
-%if %{with python2}
-ln -sf pygmentize-2 $RPM_BUILD_ROOT%{_bindir}/pygmentize
+%if %{with python3}
+ln -sf pygmentize-3 $RPM_BUILD_ROOT%{_bindir}/pygmentize
%endif
%clean
%if %{with python2}
%files
%defattr(644,root,root,755)
-%doc AUTHORS CHANGES LICENSE TODO
-%attr(755,root,root) %{_bindir}/pygmentize
+%doc AUTHORS CHANGES LICENSE README.rst
%attr(755,root,root) %{_bindir}/pygmentize-2
%{py_sitescriptdir}/%{module}
%{py_sitescriptdir}/Pygments-%{version}-py*.egg-info
%if %{with python3}
%files -n python3-%{module}
%defattr(644,root,root,755)
-%doc AUTHORS CHANGES LICENSE TODO
+%doc AUTHORS CHANGES LICENSE README.rst
+%attr(755,root,root) %{_bindir}/pygmentize
%attr(755,root,root) %{_bindir}/pygmentize-3
%{py3_sitescriptdir}/%{module}
%{py3_sitescriptdir}/Pygments-%{version}-py*.egg-info
%endif
+
+%if %{with doc}
+%files apidocs
+%defattr(644,root,root,755)
+%doc doc/_build/html/{_static,docs,*.html,*.js}
+%endif