[python-docopt/f18] Python 3 support

Martin Sivák msivak at fedoraproject.org
Fri Nov 15 11:26:07 UTC 2013


commit 8e0ed260cbb5200d4847be22a1d068a3b531354b
Author: Martin Sivak <msivak at redhat.com>
Date:   Fri Nov 15 11:48:48 2013 +0100

    Python 3 support

 python-docopt.spec |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 70 insertions(+), 2 deletions(-)
---
diff --git a/python-docopt.spec b/python-docopt.spec
index 0dd5733..6ad11fb 100644
--- a/python-docopt.spec
+++ b/python-docopt.spec
@@ -1,15 +1,31 @@
+%if 0%{?fedora} > 12
+%global with_python3 1
+%else
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
+%endif
+
+%global srcname distribute
 Name:           python-docopt
 Version:        0.6.1
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Pythonic argument parser, that will make you smile
 
 License:        MIT
 URL:            https://github.com/docopt/docopt
 Source0:        http://pypi.python.org/packages/source/d/docopt/docopt-%{version}.tar.gz
 
+%if 0%{?with_python3}
+BuildRequires:  python3-devel
+BuildRequires:  python3-setuptools
+BuildRequires:  python3-nose
+BuildRequires:  python3-pytest
+%endif
+
+BuildRequires:  python2-devel
 BuildRequires:  python-setuptools
 BuildRequires:  python-nose
-BuildRequires:  python2-devel
+BuildRequires:  pytest
+
 BuildArch:      noarch
 
 %description
@@ -21,23 +37,75 @@ generated based on the beautiful help message that you write yourself!
 This way you don't need to write thisstupid repeatable parser-code,
 and instead can write only the help message--*the way you want it*.
 
+%if 0%{?with_python3}
+%package -n python3-docopt
+Summary:        Pythonic argument parser, that will make you smile - package for Python 3
+%description -n python3-docopt
+Isn't it awesome how optparse and argparse generate help messages
+based on your code?!
+
+Hell no! You know what's awesome? It's when the option parser is
+generated based on the beautiful help message that you write yourself!
+This way you don't need to write thisstupid repeatable parser-code,
+and instead can write only the help message--*the way you want it*.
+%endif # with_python3
+
 %prep
 %setup -q -n docopt-%{version}
 
 # remove upstream egg-info
 rm -rf *.egg-info
 
+# make a copy for python3 install
+%if 0%{?with_python3}
+rm -rf %{py3dir}
+cp -a . %{py3dir}
+%endif # with_python3
+
 %build
 %{__python} setup.py build
 
+%if 0%{?with_python3}
+pushd %{py3dir}
+%{__python3} setup.py build
+popd
+%endif # with_python3
+
 %install
+
+# 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 $RPM_BUILD_ROOT
+popd
+%endif # with_python3
+
 %{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
 
+%check
+%if 0%{?with_python3}
+pushd %{py3dir}
+%{__python3} setup.py nosetests
+popd
+%endif # with_python3
+
+%{__python} setup.py nosetests
+
 %files
 %{python_sitelib}/docopt.py*
 %{python_sitelib}/docopt-*.egg-info
+%if 0%{?with_python3}
+%{python3_sitelib}/__pycache__/docopt*
+%{python3_sitelib}/docopt.py*
+%{python3_sitelib}/docopt-*.egg-info
+%endif
 
 %changelog
+* Fri Nov 15 2013 Martin Sivak <msivak at euryale.brq.redhat.com> - 0.6.1-2
+- Enable python3 package
+
 * Mon Aug 19 2013 Martin Sivak <msivak at euryale.brq.redhat.com> - 0.6.1-1
 - Upstream version sync
 


More information about the scm-commits mailing list