[python-mglob] build python3 on f16 and up
tomspur
tomspur at fedoraproject.org
Fri Jan 27 02:30:04 UTC 2012
commit 9c9304642094097d26795e1749b73c84602f7595
Author: Thomas Spura <thomas.spura at gmail.com>
Date: Fri Jan 27 03:29:52 2012 +0100
build python3 on f16 and up
mglob-0.4-built-in-set.patch | 15 ++++++++++
python-mglob.spec | 59 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 73 insertions(+), 1 deletions(-)
---
diff --git a/mglob-0.4-built-in-set.patch b/mglob-0.4-built-in-set.patch
new file mode 100644
index 0000000..4f0f3a7
--- /dev/null
+++ b/mglob-0.4-built-in-set.patch
@@ -0,0 +1,15 @@
+--- mglob.py.orig 2012-01-27 03:23:12.760751705 +0100
++++ mglob.py 2012-01-27 03:23:51.565854475 +0100
+@@ -69,7 +69,11 @@
+
+
+ import os,glob,fnmatch,sys
+-from sets import Set as set
++try:
++ from sets import Set as set
++except ImportError:
++ # we are likely running with python3, where set is built-in
++ pass
+
+
+ def expand(flist,exp_dirs = False):
diff --git a/python-mglob.spec b/python-mglob.spec
index b27b00a..85a7f5f 100644
--- a/python-mglob.spec
+++ b/python-mglob.spec
@@ -2,39 +2,83 @@
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif
+%if 0%{?fedora} > 15
+%global with_python3 1
+%endif
Name: python-mglob
Version: 0.4
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: Enhanced file name globbing module
Group: Development/Libraries
License: MIT
URL: http://pypi.python.org/pypi/mglob
Source0: http://pypi.python.org/packages/source/m/mglob/mglob-%{version}.zip
+# sent upstream via mail
+Patch0: mglob-0.4-built-in-set.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-setuptools
+%if 0%{?with_python3}
+BuildRequires: /usr/bin/2to3
+%endif
+
%description
Usable as stand-alone utility (for xargs, backticks etc.), or as a globbing
library for own python programs.
Some enhanced features are recursion, exclusion, and directory omission.
+%if 0%{?with_python3}
+%package -n python3-mglob
+Summary: Enhanced file name globbing module
+%description -n python3-mglob
+Usable as stand-alone utility (for xargs, backticks etc.), or as a globbing
+library for own python programs.
+Some enhanced features are recursion, exclusion, and directory omission.
+%endif
%prep
%setup -q -n mglob-%{version}
+%patch0
sed -i -e '/^#!\//, 1d' mglob.py
+%if 0%{?with_python3}
+rm -rf %{py3dir}
+cp -a . %{py3dir}
+find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
+
+2to3 --write --nobackups %{py3dir}
+%endif # with_python3
+
+find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'
+
%build
+%if 0%{?with_python3}
+pushd %{py3dir}
+ %{__python3} setup.py build
+popd
+%endif # with_python3
+
%{__python} setup.py build
%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 -O1 --skip-build --root %{buildroot}
+ mv %{buildroot}%{_bindir}/mglob %{buildroot}%{_bindir}/python3-mglob
+popd
+%endif # with_python3
+
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
@@ -50,8 +94,21 @@ rm -rf %{buildroot}
%{python_sitelib}/mglob.py*
%{python_sitelib}/mglob-%{version}-py?.?.egg-info
+%if 0%{with_python3}
+%files -n python3-mglob
+%defattr(-,root,root,-)
+# upstream has no docs
+%doc
+%{_bindir}/python3-mglob
+%{python3_sitelib}/__pycache__/mglob.cpython*
+%{python3_sitelib}/mglob.py*
+%{python3_sitelib}/mglob-%{version}-py?.?.egg-info
+%endif # with_python3
%changelog
+* Fri Jan 27 2012 Thomas Spura <tomspur at fedoraproject.org> - 0.4-5
+- build python3 on f16 and up
+
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
More information about the scm-commits
mailing list