- Build for python3

This commit is contained in:
Toshio Kuratomi 2010-12-30 21:07:31 -08:00
parent bee34594b1
commit 9fef4092e5

View File

@ -3,11 +3,15 @@
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%endif
%if 0%{?fedora} > 12 || 0%{?rhel} > 6
%global with_python3 1
%endif
%global srcname docutils
Name: python-%{srcname}
Version: 0.7
Release: 1%{?dist}
Release: 2%{?dist}
Summary: System for processing plaintext documentation
Group: Development/Languages
@ -20,6 +24,10 @@ BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-setuptools
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python-tools
%endif
Requires: python-imaging
Provides: docutils = %{version}-%{release}
@ -36,28 +44,87 @@ Currently, the library supports parsing rST that is in standalone files and
PEPs (Python Enhancement Proposals). Work is underway to parse rST from
Python inline documentation modules and packages.
%if 0%{?with_python3}
%package -n python3-%{srcname}
Summary: System for processing plaintext documentation for python3
Group: Development/Languages
# This module is optional and not yet available for python3
#Requires: python3-imaging
%description -n python3-%{srcname}
The Docutils project specifies a plaintext markup language, reStructuredText,
which is easy to read and quick to write. The project includes a python
library to parse rST files and transform them into other useful formats such
as HTML, XML, and TeX as well as commandline tools that give the enduser
access to this functionality.
Currently, the library supports parsing rST that is in standalone files and
PEPs (Python Enhancement Proposals). Work is underway to parse rST from
Python inline documentation modules and packages.
This package contains the module, ported to run under python3.
%endif # with_python3
%prep
%setup -q -n %{srcname}-%{version}
# Remove a shebang from one of the library files
sed -i -e '/#! *\/usr\/bin\/.*python.*/{1D}' docutils/readers/python/pynodes.py
# Remove shebang from library files
for file in docutils/_string_template_compat.py docutils/readers/python/pynodes.py ; do
sed -i -e '/#! *\/usr\/bin\/.*/{1D}' $file
done
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
# This module depends on a python2-only module. It has been removed upstream
# for the pending docutils-0.8 release
rm -rf %{py3dir}/docutils/readers/python/
rm -rf %{py3dir}/docutils/test/test_readers/test_python/
sed -i "/docutils.readers.python/d" %{py3dir}/setup.py
%endif
%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
%if 0%{?with_python3}
pushd %{py3dir}
# For roman.py
2to3 --write extras
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
# Docutils setup.py does this on build but only to the built copy, not to the
# original source. For running the tests afterwards we need to have access to everything
for dir in docutils test tools ; do
rm -rf $dir
cp -pr build/lib/$dir .
done
popd
%endif # with_python3
%install
rm -rf %{buildroot}
# Must do the python3 install first because the scripts in /usr/bin are
# overwritten with every setup.py install (and we want the python2 version
# to be the default for now).
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
# docutils setup.py runs 2to3 on a copy of the tests and puts it in sitelib.
rm -rf %{buildroot}%{python3_sitelib}/test
# docutils only installs this if its not already on the system. Due to the
# possibility that a previous version of docutils may be installed, we install
# it manually here.
file=roman.py
extradest=%{python3_sitelib}
fullextradest=%{buildroot}/$extradest
install -D -m 0644 extras/$file $fullextradest/$file
popd
%endif # with_python3
%{__python} setup.py install --skip-build --root %{buildroot}
for file in %{buildroot}/%{_bindir}/*.py; do
mv $file `dirname $file`/`basename $file .py`
done
# We want the licenses but don't need this build file
rm -f licenses/docutils.conf
# docutils only installs this if its not already on the system. Due to the
# possibility that a previous version of docutils may be installed, we install
# it manually here.
@ -66,6 +133,22 @@ extradest=%{python_sitelib}
fullextradest=%{buildroot}/$extradest
install -D -m 0644 extras/$file $fullextradest/$file
for file in %{buildroot}/%{_bindir}/*.py; do
mv $file `dirname $file`/`basename $file .py`
done
# We want the licenses but don't need this build file
rm -f licenses/docutils.conf
%check
python test/alltests.py
%if 0%{?with_python3}
pushd %{py3dir}
python3 test/alltests.py
popd
%endif
%clean
rm -rf %{buildroot}
@ -74,11 +157,18 @@ rm -rf %{buildroot}
%doc BUGS.txt COPYING.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt
%doc THANKS.txt licenses docs tools/editors
%{_bindir}/*
%{python_sitelib}/docutils/
%{python_sitelib}/roman.*
%{python_sitelib}/*egg-info
%{python_sitelib}/*
%files -n python3-%{srcname}
%defattr(-,root,root,-)
%doc BUGS.txt COPYING.txt FAQ.txt HISTORY.txt README.txt RELEASE-NOTES.txt
%doc THANKS.txt licenses docs tools/editors
%{python3_sitelib}/*
%changelog
* Thu Dec 30 2010 Toshio Kuratomi <toshio@fedoraproject.org> - 0.7-2
- Build for python3
* Sun Aug 1 2010 Toshio Kuratomi <toshio@fedoraproject.org> - 0.7-1
- Update for 0.7 release