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