[python-genshi/f21] enable python3 subpackage again as we have Babel 1.3 now in the repos
Felix Schwarz
fschwarz at fedoraproject.org
Thu Oct 30 15:40:24 UTC 2014
commit aab59d522fb0311a81af210dc1eb10426f72e6a7
Author: Felix Schwarz <felix.schwarz at oss.schwarz.eu>
Date: Thu Oct 30 12:17:20 2014 +0100
enable python3 subpackage again as we have Babel 1.3 now in the repos
...-genshi-0.7-disable-speedups-for-python34.patch | 24 ++++
python-genshi-0.7-isstring-helper.patch | 30 ++++
python-genshi-0.7-python34-ast-support.patch | 142 ++++++++++++++++++++
python-genshi.spec | 20 ++-
4 files changed, 210 insertions(+), 6 deletions(-)
---
diff --git a/python-genshi-0.7-disable-speedups-for-python34.patch b/python-genshi-0.7-disable-speedups-for-python34.patch
new file mode 100644
index 0000000..c1d67cf
--- /dev/null
+++ b/python-genshi-0.7-disable-speedups-for-python34.patch
@@ -0,0 +1,24 @@
+------------------------------------------------------------------------
+r1247 | hodgestar | 2014-02-16 19:32:21 +0100 (So, 16. Feb 2014) | 1 Zeile
+
+Disable the speedups C extension on CPython >= 3.3 since Genshi doesn't support the new Unicode C API yet.
+------------------------------------------------------------------------
+Index: setup.py
+===================================================================
+--- setup.py (Revision 1246)
++++ setup.py (Revision 1247)
+@@ -65,9 +65,13 @@
+
+
+ if Feature:
++ # Optional C extension module for speeding up Genshi:
++ # Not activated by default on:
++ # - PyPy (where it harms performance)
++ # - CPython >= 3.3 (the new Unicode C API is not supported yet)
+ speedups = Feature(
+ "optional C speed-enhancements",
+- standard = not is_pypy,
++ standard = not is_pypy and sys.version_info < (3, 3),
+ ext_modules = [
+ Extension('genshi._speedups', ['genshi/_speedups.c']),
+ ],
diff --git a/python-genshi-0.7-isstring-helper.patch b/python-genshi-0.7-isstring-helper.patch
new file mode 100644
index 0000000..4e4fca8
--- /dev/null
+++ b/python-genshi-0.7-isstring-helper.patch
@@ -0,0 +1,30 @@
+------------------------------------------------------------------------
+r1248 | hodgestar | 2014-02-16 19:43:20 +0100 (So, 16. Feb 2014) | 1 Zeile
+
+Add isstring helper.
+------------------------------------------------------------------------
+Index: genshi/compat.py
+===================================================================
+--- genshi/compat.py (Revision 1247)
++++ genshi/compat.py (Revision 1248)
+@@ -35,6 +35,15 @@
+ 'Python 2 compatibility function. Not usable in Python 3.')
+
+
++# We need to test if an object is an instance of a string type in places
++
++if IS_PYTHON2:
++ def isstring(obj):
++ return isinstance(obj, basestring)
++else:
++ def isstring(obj):
++ return isinstance(obj, str)
++
+ # We need to differentiate between StringIO and BytesIO in places
+
+ if IS_PYTHON2:
+@@ -112,4 +121,3 @@
+ if not x:
+ return False
+ return True
+-
diff --git a/python-genshi-0.7-python34-ast-support.patch b/python-genshi-0.7-python34-ast-support.patch
new file mode 100644
index 0000000..0daebf2
--- /dev/null
+++ b/python-genshi-0.7-python34-ast-support.patch
@@ -0,0 +1,142 @@
+------------------------------------------------------------------------
+r1249 | hodgestar | 2014-02-16 19:46:15 +0100 (So, 16. Feb 2014) | 1 Zeile
+
+Add support for Python 3.4 AST (support for NameConstants and changes to existing to arguments node attributes).
+------------------------------------------------------------------------
+Index: genshi/template/astutil.py
+===================================================================
+--- genshi/template/astutil.py (Revision 1248)
++++ genshi/template/astutil.py (Revision 1249)
+@@ -21,7 +21,7 @@
+ def parse(source, mode):
+ return compile(source, '', mode, _ast.PyCF_ONLY_AST)
+
+-from genshi.compat import IS_PYTHON2
++from genshi.compat import IS_PYTHON2, isstring
+
+ __docformat__ = 'restructuredtext en'
+
+@@ -103,8 +103,13 @@
+ self._new_line()
+ return self.visit(node.body)
+
++ # Python < 3.4
+ # arguments = (expr* args, identifier? vararg,
+ # identifier? kwarg, expr* defaults)
++ #
++ # Python >= 3.4
++ # arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
++ # arg? kwarg, expr* defaults)
+ def visit_arguments(self, node):
+ first = True
+ no_default_count = len(node.args) - len(node.defaults)
+@@ -122,13 +127,21 @@
+ self._write(', ')
+ else:
+ first = False
+- self._write('*' + node.vararg)
++ self._write('*')
++ if isstring(node.vararg):
++ self._write(node.vararg)
++ else:
++ self.visit(node.vararg)
+ if getattr(node, 'kwarg', None):
+ if not first:
+ self._write(', ')
+ else:
+ first = False
+- self._write('**' + node.kwarg)
++ self._write('**')
++ if isstring(node.kwarg):
++ self._write(node.kwarg)
++ else:
++ self.visit(node.kwarg)
+
+ if not IS_PYTHON2:
+ # In Python 3 arguments get a special node
+@@ -724,6 +737,17 @@
+ def visit_Name(self, node):
+ self._write(node.id)
+
++ # NameConstant(singleton value)
++ def visit_NameConstant(self, node):
++ if node.value is None:
++ self._write('None')
++ elif node.value is True:
++ self._write('True')
++ elif node.value is False:
++ self._write('False')
++ else:
++ raise Exception("Unknown NameConstant %r" % (node.value,))
++
+ # List(expr* elts, expr_context ctx)
+ def visit_List(self, node):
+ self._write('[')
+@@ -829,6 +853,7 @@
+ visit_Attribute = _clone
+ visit_Subscript = _clone
+ visit_Name = _clone
++ visit_NameConstant = _clone
+ visit_List = _clone
+ visit_Tuple = _clone
+
+Index: genshi/template/eval.py
+===================================================================
+--- genshi/template/eval.py (Revision 1248)
++++ genshi/template/eval.py (Revision 1249)
+@@ -24,7 +24,8 @@
+ from genshi.template.base import TemplateRuntimeError
+ from genshi.util import flatten
+
+-from genshi.compat import get_code_params, build_code_chunk, IS_PYTHON2
++from genshi.compat import get_code_params, build_code_chunk, isstring, \
++ IS_PYTHON2
+
+ __all__ = ['Code', 'Expression', 'Suite', 'LenientLookup', 'StrictLookup',
+ 'Undefined', 'UndefinedError']
+@@ -495,28 +496,31 @@
+ def __init__(self):
+ self.locals = [CONSTANTS]
+
++ def _process(self, names, node):
++ if not IS_PYTHON2 and isinstance(node, _ast.arg):
++ names.add(node.arg)
++ elif isstring(node):
++ names.add(node)
++ elif isinstance(node, _ast.Name):
++ names.add(node.id)
++ elif isinstance(node, _ast.alias):
++ names.add(node.asname or node.name)
++ elif isinstance(node, _ast.Tuple):
++ for elt in node.elts:
++ self._process(names, elt)
++
+ def _extract_names(self, node):
+ names = set()
+- def _process(node):
+- if not IS_PYTHON2 and isinstance(node, _ast.arg):
+- names.add(node.arg)
+- if isinstance(node, _ast.Name):
+- names.add(node.id)
+- elif isinstance(node, _ast.alias):
+- names.add(node.asname or node.name)
+- elif isinstance(node, _ast.Tuple):
+- for elt in node.elts:
+- _process(elt)
+ if hasattr(node, 'args'):
+ for arg in node.args:
+- _process(arg)
++ self._process(names, arg)
+ if hasattr(node, 'vararg'):
+- names.add(node.vararg)
++ self._process(names, node.vararg)
+ if hasattr(node, 'kwarg'):
+- names.add(node.kwarg)
++ self._process(names, node.kwarg)
+ elif hasattr(node, 'names'):
+ for elt in node.names:
+- _process(elt)
++ self._process(names, elt)
+ return names
+
+ def visit_Str(self, node):
diff --git a/python-genshi.spec b/python-genshi.spec
index a0bc758..f6fa6a6 100644
--- a/python-genshi.spec
+++ b/python-genshi.spec
@@ -1,10 +1,10 @@
-# Python3 package disabled until Babel is ported
-# http://babel.edgewall.org/ticket/209
-%global with_python3 0
+%if 0%{?fedora} > 12
+%global with_python3 1
+%endif
Name: python-genshi
Version: 0.7
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Toolkit for stream-based generation of output for the web
Group: Development/Languages
@@ -13,6 +13,9 @@ URL: http://genshi.edgewall.org/
Source0: http://ftp.edgewall.com/pub/genshi/Genshi-%{version}.tar.gz
Patch0: python-genshi-0.7-sanitizer-test-fixes.patch
+Patch1: python-genshi-0.7-disable-speedups-for-python34.patch
+Patch2: python-genshi-0.7-isstring-helper.patch
+Patch3: python-genshi-0.7-python34-ast-support.patch
BuildRequires: python2-devel
BuildRequires: python-setuptools
@@ -36,6 +39,7 @@ a template language, which is heavily inspired by Kid.
%package -n python3-genshi
Summary: Toolkit for stream-based generation of output for the web
Group: Development/Languages
+BuildArch: noarch
%description -n python3-genshi
Genshi is a Python library that provides an integrated set of
@@ -47,6 +51,9 @@ a template language, which is heavily inspired by Kid.
%prep
%setup0 -q -n Genshi-%{version}
%patch0 -p0
+%patch1 -p0
+%patch2 -p0
+%patch3 -p0
# Remove bundled egg-info in case it exists
rm -rf %{modname}.egg-info
@@ -89,13 +96,14 @@ popd
%if 0%{?with_python3}
%files -n python3-genshi
%doc ChangeLog COPYING doc examples README.txt
-%{python3_sitearch}/Genshi-%{version}-py*.egg-info
-%{python3_sitearch}/genshi
+%{python3_sitelib}/Genshi-%{version}-py*.egg-info
+%{python3_sitelib}/genshi
%endif
%changelog
* Thu Oct 30 2014 Felix Schwarz <fschwarz at fedoraproject.org> - 0.7-6
- fix tests on Python 2.7.8 (RHBZ 1106778)
+- enable python3 subpackage again as we have Babel 1.3 now in the repos
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.7-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
More information about the scm-commits
mailing list