Blob Blame History Raw
%global upstream_name Pygments

Name:           python3-pygments
Version:        2.4.2
Release:        1%{?dist}
Summary:        Syntax highlighting engine written in Python

License:        BSD
URL:            https://pygments.org/
Source0:        https://files.pythonhosted.org/packages/source/P/%{upstream_name}/%{upstream_name}-%{version}.tar.gz
# https://bugzilla.redhat.com/show_bug.cgi?id=1940605
# https://github.com/pygments/pygments/issues/1625
Patch0:		python3-pygments-CVE-2021-20270.patch
# https://github.com/pygments/pygments/issues/1637
Patch1:		python3-pygments-CVE-2021-27291.patch
BuildArch:      noarch

# For docs
BuildRequires:  python%{python3_pkgversion}-sphinx

%description
Pygments is a generic syntax highlighter for general use in all kinds
of software such as forum systems, wikis or other applications that
need to prettify source code. Highlights are:

  * a wide range of common languages and markup formats is supported
  * special attention is paid to details that increase highlighting
    quality
  * support for new languages and formats are added easily; most
    languages use a simple regex-based lexing mechanism
  * a number of output formats is available, among them HTML, RTF,
    LaTeX and ANSI sequences
  * it is usable as a command-line tool and as a library
  * ... and it highlights even Brainf*ck!


%package doc
Summary:        Documentation for Pygments

%description doc
Documentation for Pygments.


%package -n python%{python3_pkgversion}-pygments
Summary:        Syntax highlighting engine written in Python 3
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
BuildRequires:  python%{python3_pkgversion}-nose
Requires:       python%{python3_pkgversion}-setuptools

%description -n python%{python3_pkgversion}-pygments
Pygments is a generic syntax highlighter for general use in all kinds
of software such as forum systems, wikis or other applications that
need to prettify source code. Highlights are:

  * a wide range of common languages and markup formats is supported
  * special attention is paid to details that increase highlighting
    quality
  * support for new languages and formats are added easily; most
    languages use a simple regex-based lexing mechanism
  * a number of output formats is available, among them HTML, RTF,
    LaTeX and ANSI sequences
  * it is usable as a command-line tool and as a library
  * ... and it highlights even Brainf*ck!


%if 0%{?python3_other_pkgversion}
%package -n python%{python3_other_pkgversion}-pygments
Summary:        Syntax highlighting engine written in Python 3
BuildRequires:  python%{python3_other_pkgversion}-devel
BuildRequires:  python%{python3_other_pkgversion}-setuptools
BuildRequires:  python%{python3_other_pkgversion}-nose
Requires:       python%{python3_other_pkgversion}-setuptools

%description -n python%{python3_other_pkgversion}-pygments
Pygments is a generic syntax highlighter for general use in all kinds
of software such as forum systems, wikis or other applications that
need to prettify source code. Highlights are:

  * a wide range of common languages and markup formats is supported
  * special attention is paid to details that increase highlighting
    quality
  * support for new languages and formats are added easily; most
    languages use a simple regex-based lexing mechanism
  * a number of output formats is available, among them HTML, RTF,
    LaTeX and ANSI sequences
  * it is usable as a command-line tool and as a library
  * ... and it highlights even Brainf*ck!
%endif


%prep
%autosetup -p1 -n Pygments-%{version}
%{__sed} -i 's/\r//' LICENSE


%build
%py3_build
%if 0%{?python3_other_pkgversion}
%py3_other_build
%endif


%install
%py3_install
mv %{buildroot}%{_bindir}/pygmentize %{buildroot}%{_bindir}/pygmentize-%{python3_version}
%if 0%{?python3_other_pkgversion}
%py3_other_install
mv %{buildroot}%{_bindir}/pygmentize %{buildroot}%{_bindir}/pygmentize-%{python3_other_version}
%endif

make SPHINXBUILD="PYTHONPATH=.. sphinx-build-%{python3_version}" docs
install -d %{buildroot}%{_mandir}/man1
install -p -m0644 doc/pygmentize.1 %{buildroot}%{_mandir}/man1/pygmentize-%{python3_version}.1
cp -r doc/docs doc/reST
rm doc/_build/html/.buildinfo


%check
PYTHON=%{__python3} make test TEST=-v
%if 0%{?python3_other_pkgversion}
PYTHON=%{__python3_other} make test TEST=-v
%endif


%files -n python%{python3_pkgversion}-pygments
%license LICENSE
%doc AUTHORS CHANGES TODO
%{_bindir}/pygmentize-%{python3_version}
%{_mandir}/man1/*.1*
%{python3_sitelib}/*

%if 0%{?python3_other_pkgversion}
%files -n python%{python3_other_pkgversion}-pygments
%license LICENSE
%doc AUTHORS CHANGES TODO
%{_bindir}/pygmentize-%{python3_other_version}
%{_mandir}/man1/*.1*
%{python3_other_sitelib}/*
%endif

%files doc
%license LICENSE
%doc doc/_build/html doc/reST

%changelog
* Sat Jan 28 2023 Orion Poplawski <[email protected]> - 2.4.2-1
- Update to 2.4.2
- Add upstream patches for CVE-2021-20270 and  CVE-2021-27291 (bz#1940605)

* Thu Apr 04 2019 Orion Poplawski <[email protected]> - 2.2.0-3
- Build for python3_other

* Thu Mar 07 2019 Troy Dawson <[email protected]>
- Rebuilt to change main python from 3.4 to 3.6

* Tue Feb 28 2017 Orion Poplawski <[email protected]> - 2.2.0-1
- Update to 2.2.0
- Put documentation into separate package

* Wed Nov 2 2016 Orion Poplawski <[email protected]> - 2.1.3-1
- Initial EPEL version