%bcond_with test
%global with_python3 1
%global upstream_name Pygments
%global srcname pygments

Name:           python-pygments
Version:        2.6.1
Release:        1%{?_dist_release}
Summary:        A syntax highlighting engine written in Python
Group:          programming
Vendor:         Project Vine
Distribution:   Vine Linux

License:        BSD
URL:            http://pygments.org/
Source0:        https://pypi.python.org/packages/source/P/%{upstream_name}/%{upstream_name}-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      noarch
BuildRequires:  python-rpm-macros

%if 0%{?with_python3}
BuildRequires:  python3-devel, python3-setuptools, python3-nose
BuildRequires:  python3-rpm-macros
BuildRequires:  python3-sphinx
%endif # if with_python3

%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!

%if 0%{?with_python3}
%package -n python3-pygments
Summary:        A syntax highlighting engine written in Python 3
Group:          programming
Requires:       python3-setuptools
Obsoletes:      python-pygments < 2.6.0

%description -n python3-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 # if with_python3


%prep
%setup -q -n %{upstream_name}-%{version}

%build
%{__sed} -i 's/\r//' LICENSE
%if 0%{?with_python3}
%py3_build
%endif


%install
%__rm -rf $RPM_BUILD_ROOT

%if 0%{?with_python3}
# Python 3 install
%py3_install
%endif

%{__python3} setup.py build_sphinx
pushd doc
install -d %{buildroot}%{_mandir}/man1
mv pygmentize.1 $RPM_BUILD_ROOT%{_mandir}/man1/pygmentize.1
popd
cp -r doc/docs doc/reST


%clean
%__rm -rf $RPM_BUILD_ROOT


%if %{with test}
%check
make test PYTHON=%{__python}
%if 0%{?with_python3}
make test PYTHON=%{__python3}
%endif
%endif


%if 0%{?with_python3}
%files -n python3-pygments
%defattr(-,root,root,-)
%doc AUTHORS CHANGES build/sphinx/html doc/reST TODO
%license LICENSE
%{python3_sitelib}/*
%{_bindir}/pygmentize
%lang(en) %{_mandir}/man1/pygmentize.1*
%endif # with_python3


%changelog
* Sun Aug 16 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.6.1-1
- new upstream release.
- built with python3 only.

* Sat Feb 15 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.5.2-1
- new upstream release.

* Thu Nov 29 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.3.0-2
- packed pygmentize for python2.

* Tue Nov 27 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.3.0-1
- new upstream release.
- added python3 support.

* Tue Jul 12 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 2.1.3-1
- new upstream release.

* Sun Jan 12 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.3.1-3
- rebuild with VineSeed environment

* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 1.3.1-2
- rebuild with python-2.7.2

* Mon Aug 23 2010 Munehiro Yamamoto <munepi@vinelinux.org> - 1.3.1-1
- initial build based on Fedora development

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

* Thu May  6 2010 Gareth Armstrong <gareth.armstrong@hp.com> - 1.3.1-5
- Enforce that Pygments requires Python 2.4 or later via an explicit BR
- Minor tweaks to spec file
- Deliver html and reST doc files to specifically named directories
- Align description with that of http://pygments.org/
- Add %%check section for Python2 and add BR on python-nose

* Fri Apr 23 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-4
- switched with_python3 back to 1

* Fri Apr 23 2010 David Malcolm <dmalcolm@redhat.com> - 1.3.1-3
- add python3 subpackage (BZ#537244), ignoring soft-dep on imaging for now

* Tue Apr 13 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-2
- added python-imaging as a dependency per BZ#581663.

* Sat Mar  6 2010 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.3.1-1
- Updated for release.

* Tue Sep 29 2009 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.1.1-1
- Updated for release.

* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Sun Dec 21 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.0-3
- Updated for release.

* Sat Nov 29 2008 Ignacio Vazquez-Abrams <ivazqueznet+rpm@gmail.com> - 1.0-2
- Rebuild for Python 2.6

* Thu Nov 27 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 1.0-1
- Updated for upstream 1.0.

* Sun Sep 14 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.11.1-1
- Updated for upstream 0.11.

* Mon Jul 21 2008 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.10-1
- Updated for upstream 0.10.

* Thu Nov 29 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.9-2
- Added python-setuptools as a Requires per bz#403601.

* Mon Nov 12 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.9-1
- Updated for upstream 0.9.

* Fri Aug 17 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.8.1-2
- Removed the dos2unix build dependency.

* Thu Jun 28 2007 Steve 'Ashcrow' Milner <me@stevemilner.org> - 0.8.1-1
- Initial packaging for Fedora.