033a7e
%global debug_package %{nil}
033a7e
# python2X and python3X are built form the same module, so we need a conditional
033a7e
# for python[23] bits the state of the conditional is not important in the spec,
033a7e
# it is set in modulemd
033a7e
%bcond_without python2
033a7e
%bcond_without python3
033a7e
%bcond_with python36_module
033a7e
033a7e
%if %{without python3}
033a7e
%bcond_with doc
033a7e
%else
033a7e
%bcond_without doc
033a7e
%endif
033a7e
033a7e
%bcond_without tests
033a7e
033a7e
%global upstream_name Pygments
033a7e
%global srcname pygments
033a7e
%global sum Syntax highlighting engine written in Python
033a7e
033a7e
Name:           python-pygments
033a7e
Version:        2.2.0
444e02
Release:        22%{?dist}
033a7e
Summary:        %{sum}
033a7e
033a7e
License:        BSD
033a7e
URL:            http://pygments.org/
033a7e
Source0:        https://pypi.org/packages/source/P/%{upstream_name}/%{upstream_name}-%{version}.tar.gz
033a7e
Patch0:         import-directive.patch
033a7e
BuildArch:      noarch
033a7e
033a7e
# Fix CVE-2021-20270: infinite loop in SML lexer which may lead to DoS
033a7e
# Resolved upstream: https://github.com/pygments/pygments/commit/f91804ff4772e3ab41f46e28d370f57898700333
033a7e
Patch1:         CVE-2021-20270-infinite-loop-in-SML-lexer.patch
033a7e
444e02
# CVE-2021-27291: ReDos via crafted malicious input
444e02
# Tracking bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2021-27291
444e02
# Upstream fix: https://github.com/pygments/pygments/commit/2e7e8c4a7b318f4032493773732754e418279a14
444e02
Patch2:         CVE-2021-27291.patch
444e02
033a7e
%if %{with python3}
033a7e
BuildRequires:  python3-sphinx
033a7e
%endif
033a7e
033a7e
%description
033a7e
Pygments is a generic syntax highlighter for general use in all kinds
033a7e
of software such as forum systems, wikis or other applications that
033a7e
need to prettify source code. Highlights are:
033a7e
033a7e
  * a wide range of common languages and markup formats is supported
033a7e
  * special attention is paid to details that increase highlighting
033a7e
    quality
033a7e
  * support for new languages and formats are added easily; most
033a7e
    languages use a simple regex-based lexing mechanism
033a7e
  * a number of output formats is available, among them HTML, RTF,
033a7e
    LaTeX and ANSI sequences
033a7e
  * it is usable as a command-line tool and as a library
033a7e
  * ... and it highlights even Brainf*ck!
033a7e
033a7e
033a7e
%if %{with python2}
033a7e
%package -n python2-%{srcname}
033a7e
BuildRequires:  python2-devel >= 2.4
033a7e
BuildRequires:  python2-setuptools
033a7e
BuildRequires:  python2-nose
033a7e
Summary:        %{sum}
033a7e
%{?python_provide:%python_provide python2-%{srcname}}
033a7e
033a7e
%description -n python2-%{srcname}
033a7e
Pygments is a generic syntax highlighter for general use in all kinds
033a7e
of software such as forum systems, wikis or other applications that
033a7e
need to prettify source code. Highlights are:
033a7e
033a7e
  * a wide range of common languages and markup formats is supported
033a7e
  * special attention is paid to details that increase highlighting
033a7e
    quality
033a7e
  * support for new languages and formats are added easily; most
033a7e
    languages use a simple regex-based lexing mechanism
033a7e
  * a number of output formats is available, among them HTML, RTF,
033a7e
    LaTeX and ANSI sequences
033a7e
  * it is usable as a command-line tool and as a library
033a7e
  * ... and it highlights even Brainf*ck!
033a7e
%endif
033a7e
033a7e
033a7e
%if %{with python3}
033a7e
%package -n python3-%{srcname}
033a7e
%if %{with python36_module}
033a7e
BuildRequires:  python36-devel
033a7e
BuildRequires:  python36-rpm-macros
033a7e
%else
033a7e
BuildRequires:  python3-devel
033a7e
%endif
033a7e
BuildRequires:  python3-setuptools, python3-nose
033a7e
Summary:        %{sum}
033a7e
%{?python_provide:%python_provide python3-%{srcname}}
033a7e
033a7e
%description -n python3-%{srcname}
033a7e
Pygments is a generic syntax highlighter for general use in all kinds
033a7e
of software such as forum systems, wikis or other applications that
033a7e
need to prettify source code. Highlights are:
033a7e
033a7e
  * a wide range of common languages and markup formats is supported
033a7e
  * special attention is paid to details that increase highlighting
033a7e
    quality
033a7e
  * support for new languages and formats are added easily; most
033a7e
    languages use a simple regex-based lexing mechanism
033a7e
  * a number of output formats is available, among them HTML, RTF,
033a7e
    LaTeX and ANSI sequences
033a7e
  * it is usable as a command-line tool and as a library
033a7e
  * ... and it highlights even Brainf*ck!
033a7e
%endif
033a7e
033a7e
%prep
033a7e
%setup -q -n %{upstream_name}-%{version}
033a7e
%patch0 -p 1
033a7e
%patch1 -p1
444e02
%patch2 -p1
033a7e
033a7e
%build
033a7e
%{__sed} -i 's/\r//' LICENSE
033a7e
%{?with_python2:%py2_build}
033a7e
%{?with_python3:%py3_build}
033a7e
%{?with_doc:%{__python3} setup.py build_sphinx}
033a7e
033a7e
%install
033a7e
# Python 2 install
033a7e
# NOTE: sphinx is built on Python 3 and packages with python2 and python3
033a7e
%if %{with python2}
033a7e
%py2_install
033a7e
mv %{buildroot}%{_bindir}/pygmentize{,-%{python2_version}}
033a7e
ln -s pygmentize-%{python2_version} %{buildroot}%{_bindir}/pygmentize-2
033a7e
%endif
033a7e
033a7e
%if %{with doc}
033a7e
pushd doc
033a7e
install -d %{buildroot}%{_mandir}/man1
033a7e
mv pygmentize.1 $RPM_BUILD_ROOT%{_mandir}/man1/pygmentize.1
033a7e
popd
033a7e
cp -r doc/docs doc/reST
033a7e
%endif
033a7e
033a7e
%if %{with python3}
033a7e
%py3_install
033a7e
cp %{buildroot}%{_bindir}/pygmentize{,-%{python3_version}}
033a7e
ln -s pygmentize-%{python3_version} %{buildroot}%{_bindir}/pygmentize-3
033a7e
%endif
033a7e
033a7e
%check
033a7e
%if %{with tests}
033a7e
%{?with_python2:make test PYTHON=%{__python2}}
033a7e
%{?with_python3:make test PYTHON=%{__python3}}
033a7e
%endif
033a7e
033a7e
%if %{with python2}
033a7e
%files -n python2-pygments
033a7e
%doc AUTHORS CHANGES TODO
033a7e
%if %{with doc}
033a7e
%doc build/sphinx/html doc/reST
033a7e
%lang(en) %{_mandir}/man1/pygmentize.1*
033a7e
%endif
033a7e
%license LICENSE
033a7e
%{python2_sitelib}/*
033a7e
%{_bindir}/pygmentize-2
033a7e
%{_bindir}/pygmentize-%{python2_version}
033a7e
%endif
033a7e
033a7e
%if %{with python3}
033a7e
%files -n python3-pygments
033a7e
%doc AUTHORS CHANGES TODO
033a7e
%if %{with doc}
033a7e
%doc build/sphinx/html doc/reST
033a7e
%lang(en) %{_mandir}/man1/pygmentize.1*
033a7e
%endif
033a7e
%license LICENSE
033a7e
%{python3_sitelib}/*
033a7e
%{_bindir}/pygmentize
033a7e
%{_bindir}/pygmentize-3
033a7e
%{_bindir}/pygmentize-%{python3_version}
033a7e
%endif
033a7e
033a7e
%changelog
444e02
* Thu Apr 22 2021 Lumír Balhar <lbalhar@redhat.com> - 2.2.0-22
444e02
- Fix CVE-2021-27291: ReDos via crafted malicious input
444e02
Resolves: rhbz#1943459 rhbz#1943460
444e02
033a7e
* Wed Mar 03 2021 Charalampos Stratakis <cstratak@redhat.com> - 2.2.0-21
033a7e
- Fix CVE-2021-20270: infinite loop in SML lexer which may lead to DoS
033a7e
Resolves: rhbz#1933876
033a7e
033a7e
* Thu Apr 25 2019 Tomas Orsava <torsava@redhat.com> - 2.2.0-20
033a7e
- Bumping due to problems with modular RPM upgrade path
033a7e
- Resolves: rhbz#1695587
033a7e
033a7e
* Mon Sep 17 2018 Lumír Balhar <lbalhar@redhat.com> - 2.2.0-19
033a7e
- Get rid of unversioned Python dependencies
033a7e
- Resolves: rhbz#1628242
033a7e
033a7e
* Wed Aug 08 2018 Lumír Balhar <lbalhar@redhat.com> - 2.2.0-18
033a7e
- Remove unversioned binaries from python2 subpackage
033a7e
- Resolves: rhbz#1613343
033a7e
033a7e
* Wed Aug 01 2018 Lumír Balhar <lbalhar@redhat.com> - 2.2.0-17
033a7e
- Specfile cleanup
033a7e
- Condition for tests
033a7e
- Condition for doc
033a7e
033a7e
* Tue Jul 31 2018 Lumír Balhar <lbalhar@redhat.com> - 2.2.0-16
033a7e
- Switch python3 coditions to bcond
033a7e
033a7e
* Wed Jul 18 2018 Tomas Orsava <torsava@redhat.com> - 2.2.0-15
033a7e
- BuildRequire also python36-rpm-macros as part of the python36 module build
033a7e
033a7e
* Wed Jul 04 2018 Miro Hrončok <mhroncok@redhat.com> - 2.2.0-14
033a7e
- Add a bcond for python2
033a7e
- Fix the test invocation
033a7e
033a7e
* Thu Jun 14 2018 Tomas Orsava <torsava@redhat.com> - 2.2.0-13
033a7e
- Switch to using Python 3 version of sphinx
033a7e
033a7e
* Mon Apr 30 2018 Tomas Orsava <torsava@redhat.com> - 2.2.0-12
033a7e
- Require the python36-devel package when building for the python36 module
033a7e
033a7e
* Mon Mar 19 2018 Steve Milner <smilner@redhat.com> - 2.2.0-11
033a7e
- Added import-directive.patch to work around a change in sphinx.
033a7e
033a7e
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.0-10
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
033a7e
033a7e
* Fri Sep 29 2017 Troy Dawson <tdawson@redhat.com> - 2.2.0-9
033a7e
- Cleanup spec file conditionals
033a7e
033a7e
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.2.0-8
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
033a7e
033a7e
* Thu Mar 22 2017 Steve Milner <smilner@redhat.com> - 2.2.0-7
033a7e
- Fixed python2 sitelib in files section.
033a7e
033a7e
* Wed Mar 22 2017 Steve Milner <smilner@redhat.com> - 2.2.0-6
033a7e
- Dropped python26 support.
033a7e
- Spec clean up
033a7e
033a7e
* Mon Mar 20 2017 Steve Milner <smilner@redhat.com> - 2.2.0-5
033a7e
- Updated for standards per BZ#1433650
033a7e
033a7e
* Mon Mar  6 2017 Steve Milner <smilner@redhat.com> - 2.2.0-4
033a7e
- Added conflict per BZ#1429075
033a7e
033a7e
* Mon Mar  6 2017 Steve Milner <smilner@redhat.com> - 2.2.0-3
033a7e
- Python3 package now houses the pygmentize binary
033a7e
- Fixed Source0 url to point to pypi.org
033a7e
- Made python3-nose a hard BuildRequirement for python3
033a7e
033a7e
* Thu Mar  2 2017 Steve Milner <smilner@redhat.com> - 2.2.0-2
033a7e
- Update bin to come back into line with Fedora standards
033a7e
033a7e
* Thu Mar  2 2017 Steve Milner <smilner@redhat.com> - 2.2.0-1
033a7e
- Update for upstream release.
033a7e
033a7e
* Thu Mar  2 2017 Steve Milner <smilner@redhat.com> - 2.1.3-5
033a7e
- Split bin between versions.
033a7e
033a7e
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.3-4
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
033a7e
033a7e
* Mon Dec 12 2016 Charalampos Stratakis <cstratak@redhat.com> - 2.1.3-3
033a7e
- Rebuild for Python 3.6
033a7e
- Don't make rpmbuild fail on failed tests for now
033a7e
033a7e
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.1.3-2
033a7e
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
033a7e
033a7e
* Fri Mar  4 2016 Steve Milner <smilner@redhat.com> - 2.1.3-1
033a7e
- Update for upstream release.
033a7e
033a7e
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.2-5
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
033a7e
033a7e
* Thu Nov 12 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.2-4
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
033a7e
033a7e
* Thu Oct 29 2015 Steve Milner <smilner@redhat.com> - 2.0.2-3
033a7e
- Backport patch to fix font manager shell injection for BZ#1276321
033a7e
033a7e
* Mon Oct 12 2015 Robert Kuska <rkuska@redhat.com> - 2.0.2-2
033a7e
- Rebuilt for Python3.5 rebuild
033a7e
- Also remove python3-sphinx from BR as docs are built only with python2-sphinx
033a7e
033a7e
* Mon Aug 24 2015 Steve Milner <smilner@redhat.com> - 2.0.2-1
033a7e
- update for upstream release.
033a7e
- Added python-pygments/python3-pygments to BuildRequires.
033a7e
033a7e
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6-4
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
033a7e
033a7e
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6-3
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
033a7e
033a7e
* Sat May 10 2014 Orion Poplawski <orion@cora.nwra.com> - 1.6-2
033a7e
- Rebuild for Python 3.4
033a7e
033a7e
* Tue Nov 26 2013 Steve Milner <smilner@fedoraproject.org> - 1.6-1
033a7e
- update for upstream release.
033a7e
033a7e
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-9
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
033a7e
033a7e
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-8
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
033a7e
033a7e
* Sat Aug 04 2012 David Malcolm <dmalcolm@redhat.com> - 1.4-7
033a7e
- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3
033a7e
033a7e
* Fri Aug  3 2012 David Malcolm <dmalcolm@redhat.com> - 1.4-6
033a7e
- remove rhel logic from with_python3 conditional
033a7e
033a7e
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-5
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
033a7e
033a7e
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4-4
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
033a7e
033a7e
* Tue Sep 13 2011 Toshio Kuratomi <toshio@fedoraproject.org> - 1.4-3
033a7e
- Really enable the python3 unittests.
033a7e
- Fix python26 byte compilation (thanks to Jeffrey Ness)
033a7e
033a7e
* Sat Sep 10 2011 Toshio Kuratomi <toshio@fedoraproject.org> - 1.4-2
033a7e
- Fix python main package having dependencies for the python2.6 subpackage
033a7e
- Fix places that used the default python instead of python26
033a7e
- Attempt to make byte compilation more robust in case we add python3 to EPEL5
033a7e
- Run unittests on python3 in F15+
033a7e
033a7e
* Fri Jun 24 2011 Steve Milner <smilner@fedoraproject.org> - 1.4-1
033a7e
- update for upstream release
033a7e
- Add python2.6 support done by Steve Traylen <steve.traylen@cern.ch>. BZ#662755.
033a7e
033a7e
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-8
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
033a7e
033a7e
* Wed Aug 25 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.3.1-7
033a7e
- update to most recent python guidelines
033a7e
- rebuild with python3.2
033a7e
  http://lists.fedoraproject.org/pipermail/devel/2010-August/141368.html
033a7e
033a7e
* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 1.3.1-6
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
033a7e
033a7e
* Thu May  6 2010 Gareth Armstrong <gareth.armstrong@hp.com> - 1.3.1-5
033a7e
- Enforce that Pygments requires Python 2.4 or later via an explicit BR
033a7e
- Minor tweaks to spec file
033a7e
- Deliver html and reST doc files to specifically named directories
033a7e
- Align description with that of http://pygments.org/
033a7e
- Add %%check section for Python2 and add BR on python-nose
033a7e
033a7e
* Fri Apr 23 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-4
033a7e
- switched with_python3 back to 1
033a7e
033a7e
* Fri Apr 23 2010 David Malcolm <dmalcolm@redhat.com> - 1.3.1-3
033a7e
- add python3 subpackage (BZ#537244), ignoring soft-dep on imaging for now
033a7e
033a7e
* Tue Apr 13 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-2
033a7e
- added python-imaging as a dependency per BZ#581663.
033a7e
033a7e
* Sat Mar  6 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-1
033a7e
- Updated for release.
033a7e
033a7e
* Tue Sep 29 2009 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.1.1-1
033a7e
- Updated for release.
033a7e
033a7e
* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-5
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
033a7e
033a7e
* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-4
033a7e
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
033a7e
033a7e
* Sun Dec 21 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.0-3
033a7e
- Updated for release.
033a7e
033a7e
* Sat Nov 29 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm@gmail.com> - 1.0-2
033a7e
- Rebuild for Python 2.6
033a7e
033a7e
* Thu Nov 27 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.0-1
033a7e
- Updated for upstream 1.0.
033a7e
033a7e
* Sun Sep 14 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.11.1-1
033a7e
- Updated for upstream 0.11.
033a7e
033a7e
* Mon Jul 21 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.10-1
033a7e
- Updated for upstream 0.10.
033a7e
033a7e
* Thu Nov 29 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.9-2
033a7e
- Added python-setuptools as a Requires per bz#403601.
033a7e
033a7e
* Mon Nov 12 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.9-1
033a7e
- Updated for upstream 0.9.
033a7e
033a7e
* Fri Aug 17 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.8.1-2
033a7e
- Removed the dos2unix build dependency.
033a7e
033a7e
* Thu Jun 28 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.8.1-1
033a7e
- Initial packaging for Fedora.