1
0
mirror of https://github.com/edgewall/genshi.git synced 2026-02-05 06:45:30 +01:00

py3k branch: 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)

This commit is contained in:
Simon Cross
2010-10-24 21:09:36 +00:00
parent ac2fd68c31
commit 4c1cf760f2
5 changed files with 54 additions and 4 deletions

View File

@@ -2,3 +2,4 @@ exclude doc/2000ft.graffle
recursive-exclude doc/logo.lineform *
include doc/api/*.*
include doc/*.html
recursive-include genshi/template/tests/templates *.html *.txt

8
examples_to_py3k.sh Normal file
View File

@@ -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/

0
fixes/__init__.py Normal file
View File

View File

@@ -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

View File

@@ -41,7 +41,8 @@ class optional_build_ext(build_ext):
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 @@ class optional_build_ext(build_ext):
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 @@ if bdist_egg:
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 @@ feature is a template language, which is heavily inspired by Kid.""",
'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 @@ feature is a template language, which is heavily inspired by Kid.""",
""",
features = {'speedups': speedups},
cmdclass = cmdclass
cmdclass = cmdclass,
**extra
)