Mercurial > genshi > genshi-test
changeset 929:1a86e0af2ae1
Merge r1137 from py3k: add 2to3 build infrastructure to setup.py (this pulls the tests into the source distribution so that tests can be run after building with 2to3)
author | hodgestar |
---|---|
date | Fri, 18 Mar 2011 09:02:22 +0000 |
parents | 7dae2a055543 |
children | 0ec0a695ec96 |
files | MANIFEST.in examples_to_py3k.sh fixes/__init__.py fixes/fix_unicode_in_strings.py setup.py |
diffstat | 5 files changed, 54 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ recursive-exclude doc/logo.lineform * include doc/api/*.* include doc/*.html +recursive-include genshi/template/tests/templates *.html *.txt
new file mode 100644 --- /dev/null +++ b/examples_to_py3k.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# +# Script to run 2to3 on files not covered by setup.py +# +export PYTHONIOENCODING=utf8 + +# General 2to3 run +2to3 -w --no-diffs examples/
new file mode 100644 --- /dev/null +++ b/fixes/fix_unicode_in_strings.py @@ -0,0 +1,17 @@ +"""Fixer that changes expressions inside strings literals from u"..." to "...". + +""" + +import re +from lib2to3 import fixer_base + +_literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])") + +class FixUnicodeInStrings(fixer_base.BaseFix): + + PATTERN = "STRING" + + def transform(self, node, results): + new = node.clone() + new.value = _literal_re.sub(r"\1\2", new.value) + return new
--- a/setup.py +++ b/setup.py @@ -41,7 +41,8 @@ def run(self): try: build_ext.run(self) - except DistutilsPlatformError, e: + except DistutilsPlatformError: + _etype, e, _tb = sys.exc_info() self._unavailable(e) def build_extension(self, ext): @@ -49,7 +50,8 @@ build_ext.build_extension(self, ext) global _speedup_available _speedup_available = True - except CCompilerError, e: + except CCompilerError: + _etype, e, _tb = sys.exc_info() self._unavailable(e) def _unavailable(self, exc): @@ -86,6 +88,25 @@ cmdclass['bdist_egg'] = my_bdist_egg +# Use 2to3 if we're running under Python 3 (with Distribute) +extra = {} +if sys.version_info >= (3,): + extra['use_2to3'] = True + extra['convert_2to3_doctests'] = [] + extra['use_2to3_fixers'] = ['fixes'] + # include tests for python3 setup.py test + packages = [ + 'genshi', 'genshi.filters', 'genshi.template', + 'genshi.tests', 'genshi.filters.tests', + 'genshi.template.tests', + 'genshi.template.tests.templates', + ] + # Install genshi template tests + extra['include_package_data'] = True +else: + packages = ['genshi', 'genshi.filters', 'genshi.template'] + + setup( name = 'Genshi', version = '0.7', @@ -108,13 +129,14 @@ 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', + 'Programming Language :: Python :: 3', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Processing :: Markup :: HTML', 'Topic :: Text Processing :: Markup :: XML' ], keywords = ['python.templating.engines'], - packages = ['genshi', 'genshi.filters', 'genshi.template'], + packages = packages, test_suite = 'genshi.tests.suite', extras_require = { @@ -132,5 +154,7 @@ """, features = {'speedups': speedups}, - cmdclass = cmdclass + cmdclass = cmdclass, + + **extra )