Modernize spec

This commit is contained in:
Miro Hrončok 2018-08-17 14:54:10 +02:00
parent 4adf7b746c
commit a3401df083

View File

@ -1,7 +1,3 @@
%if 0%{?fedora} || 0%{?rhel} > 7
%global with_python3 0%{!?_without_python3:1}
%endif
%global srcname docutils %global srcname docutils
Name: python-%{srcname} Name: python-%{srcname}
@ -9,7 +5,6 @@ Version: 0.14
Release: 5%{?dist} Release: 5%{?dist}
Summary: System for processing plaintext documentation Summary: System for processing plaintext documentation
Group: Development/Languages
# See COPYING.txt for information # See COPYING.txt for information
License: Public Domain and BSD and Python and GPLv3+ License: Public Domain and BSD and Python and GPLv3+
URL: http://docutils.sourceforge.net URL: http://docutils.sourceforge.net
@ -25,10 +20,8 @@ BuildArch: noarch
BuildRequires: python2-devel BuildRequires: python2-devel
BuildRequires: python2-setuptools BuildRequires: python2-setuptools
%if 0%{?with_python3}
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python2-tools BuildRequires: python3-setuptools
%endif
%description %description
The Docutils project specifies a plaintext markup language, reStructuredText, The Docutils project specifies a plaintext markup language, reStructuredText,
@ -44,8 +37,6 @@ Python inline documentation modules and packages.
%package -n python2-%{srcname} %package -n python2-%{srcname}
Summary: System for processing plaintext documentation for python2 Summary: System for processing plaintext documentation for python2
%{?python_provide:%python_provide python2-%{srcname}} %{?python_provide:%python_provide python2-%{srcname}}
Provides: docutils = %{version}-%{release}
Obsoletes: docutils < %{version}-%{release}
%description -n python2-%{srcname} %description -n python2-%{srcname}
The Docutils project specifies a plaintext markup language, reStructuredText, The Docutils project specifies a plaintext markup language, reStructuredText,
@ -58,11 +49,9 @@ Currently, the library supports parsing rST that is in standalone files and
PEPs (Python Enhancement Proposals). Work is underway to parse rST from PEPs (Python Enhancement Proposals). Work is underway to parse rST from
Python inline documentation modules and packages. Python inline documentation modules and packages.
%if 0%{?with_python3}
%package -n python3-%{srcname} %package -n python3-%{srcname}
Summary: System for processing plaintext documentation for python3 Summary: System for processing plaintext documentation for python3
%{?python_provide:%python_provide python3-%{srcname}} %{?python_provide:%python_provide python3-%{srcname}}
Group: Development/Languages
%description -n python3-%{srcname} %description -n python3-%{srcname}
The Docutils project specifies a plaintext markup language, reStructuredText, The Docutils project specifies a plaintext markup language, reStructuredText,
@ -76,10 +65,14 @@ PEPs (Python Enhancement Proposals). Work is underway to parse rST from
Python inline documentation modules and packages. Python inline documentation modules and packages.
This package contains the module, ported to run under python3. This package contains the module, ported to run under python3.
%endif # with_python3
%prep %prep
%setup -q -n %{srcname}-%{version} %autosetup -c -n %{srcname}-%{version}
# Upstream needs separate python2 and 3 folders as it utilizes 2to3 in
# a custom hackish way
pushd %{srcname}-%{version}
# Remove shebang from library files # Remove shebang from library files
for file in docutils/utils/{code_analyzer.py,punctuation_chars.py,error_reporting.py,smartquotes.py} docutils/utils/math/{latex2mathml.py,math2html.py} docutils/writers/xetex/__init__.py; do for file in docutils/utils/{code_analyzer.py,punctuation_chars.py,error_reporting.py,smartquotes.py} docutils/utils/math/{latex2mathml.py,math2html.py} docutils/writers/xetex/__init__.py; do
@ -89,80 +82,81 @@ done
iconv -f ISO88592 -t UTF8 tools/editors/emacs/IDEAS.rst > tmp iconv -f ISO88592 -t UTF8 tools/editors/emacs/IDEAS.rst > tmp
mv tmp tools/editors/emacs/IDEAS.rst mv tmp tools/editors/emacs/IDEAS.rst
%if 0%{?with_python3} popd
rm -rf %{py3dir}
cp -a . %{py3dir} # Create the two folders mentioned above
%endif mv %{srcname}-%{version} python3
cp -rp python3 python2
# Get the doc and license files out
pushd python3
cp -rp COPYING.txt licenses BUGS.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt THANKS.txt tools/editors ..
popd
# We want the licenses but don't need this build file
rm -f licenses/docutils.conf
%build %build
pushd python2
%py2_build %py2_build
popd
%if 0%{?with_python3} pushd python3
pushd %{py3dir}
%py3_build %py3_build
popd popd
%endif # with_python3
%install %install
pushd python2
%py2_install %py2_install
# Flash file is used for testing docutils but shouldn't be in the installed package.
mv docs/user/rst/images/biohazard.swf ./biohazard.swf
popd
rm -f %{buildroot}/%{_bindir}/*
pushd python3
%py3_install
mv docs/user/rst/images/biohazard.swf ./biohazard.swf
popd
# docutils setup.py runs 2to3 on a copy of the tests and puts it in sitelib. # docutils setup.py runs 2to3 on a copy of the tests and puts it in sitelib.
rm -rf %{buildroot}%{python3_sitelib}/test rm -rf %{buildroot}%{python3_sitelib}/test
# Flash file is used for testing docutils but shouldn't be in the installed package.
mv docs/user/rst/images/biohazard.swf ./biohazard.swf
%if 0%{?with_python3}
rm -f %{buildroot}/%{_bindir}/*
%endif # with_python3
%if 0%{?with_python3}
pushd %{py3dir}
%py3_install
# We want the licenses but don't need this build file
rm -f licenses/docutils.conf
# Flash file is used for testing docutils but shouldn't be in the installed package.
mv docs/user/rst/images/biohazard.swf ./biohazard.swf
popd
%endif # with_python3
for file in %{buildroot}/%{_bindir}/*.py; do for file in %{buildroot}/%{_bindir}/*.py; do
mv $file `dirname $file`/`basename $file .py` mv $file `dirname $file`/`basename $file .py`
done done
%check %check
mv biohazard.swf docs/user/rst/images/biohazard.swf for PY in 2 3; do
python2 test/alltests.py pushd python${PY}
rm docs/user/rst/images/biohazard.swf mv biohazard.swf docs/user/rst/images/biohazard.swf
python${PY} test${PY/2/}/alltests.py
rm docs/user/rst/images/biohazard.swf
popd
done
%if 0%{?with_python3}
pushd %{py3dir}
mv biohazard.swf docs/user/rst/images/biohazard.swf
python3 test3/alltests.py
rm docs/user/rst/images/biohazard.swf
popd
%endif
%files -n python2-%{srcname} %files -n python2-%{srcname}
%license COPYING.txt licenses/* %license COPYING.txt licenses/*
%doc BUGS.txt COPYING.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt %doc BUGS.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt
%doc THANKS.txt docs tools/editors %doc THANKS.txt python2/docs editors
%{python2_sitelib}/* %{python2_sitelib}/%{srcname}/
%{python2_sitelib}/%{srcname}-%{version}-py%{python2_version}.egg-info
%if 0%{?with_python3}
%files -n python3-%{srcname} %files -n python3-%{srcname}
%license COPYING.txt licenses/* %license COPYING.txt licenses/*
%doc BUGS.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt %doc BUGS.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt
%doc THANKS.txt docs tools/editors %doc THANKS.txt python3/docs editors
%{python3_sitelib}/* %{python3_sitelib}/%{srcname}/
%endif %{python3_sitelib}/%{srcname}-%{version}-py%{python3_version}.egg-info
# Leave this at the end to end up in the proper one
%{_bindir}/* %{_bindir}/*
%changelog %changelog
* Thu Jul 12 2018 Miro Hrončok <mhroncok@redhat.com> - 0.14-5 * Thu Jul 12 2018 Miro Hrončok <mhroncok@redhat.com> - 0.14-5
- Only ship one version of the rst2* executables - Only ship one version of the rst2* executables