Edgewall Software

source: trunk/setup.py

Last change on this file was 1247, checked in by hodgestar, 10 years ago

Disable the speedups C extension on CPython >= 3.3 since Genshi doesn't support the new Unicode C API yet.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2006-2010 Edgewall Software
5# All rights reserved.
6#
7# This software is licensed as described in the file COPYING, which
8# you should have received as part of this distribution. The terms
9# are also available at http://genshi.edgewall.org/wiki/License.
10#
11# This software consists of voluntary contributions made by many
12# individuals. For the exact contribution history, see the revision
13# history and logs, available at http://genshi.edgewall.org/log/.
14
15from distutils.cmd import Command
16from distutils.command.build_ext import build_ext
17from distutils.errors import CCompilerError, DistutilsPlatformError
18import doctest
19from glob import glob
20import os
21try:
22    from setuptools import setup, Extension, Feature
23    from setuptools.command.bdist_egg import bdist_egg
24except ImportError:
25    from distutils.core import setup, Extension
26    Feature = None
27    bdist_egg = None
28import sys
29
30sys.path.append(os.path.join('doc', 'common'))
31try:
32    from doctools import build_doc, test_doc
33except ImportError:
34    build_doc = test_doc = None
35
36_speedup_available = False
37
38is_pypy = hasattr(sys, 'pypy_version_info')
39
40class optional_build_ext(build_ext):
41    # This class allows C extension building to fail.
42    def run(self):
43        try:
44            build_ext.run(self)
45        except DistutilsPlatformError:
46            _etype, e, _tb = sys.exc_info()
47            self._unavailable(e)
48
49    def build_extension(self, ext):
50        try:
51            build_ext.build_extension(self, ext)
52            global _speedup_available
53            _speedup_available = True
54        except CCompilerError:
55            _etype, e, _tb = sys.exc_info()
56            self._unavailable(e)
57
58    def _unavailable(self, exc):
59        print('*' * 70)
60        print("""WARNING:
61An optional C extension could not be compiled, speedups will not be
62available.""")
63        print('*' * 70)
64        print(exc)
65
66
67if Feature:
68    # Optional C extension module for speeding up Genshi:
69    # Not activated by default on:
70    # - PyPy (where it harms performance)
71    # - CPython >= 3.3 (the new Unicode C API is not supported yet)
72    speedups = Feature(
73        "optional C speed-enhancements",
74        standard = not is_pypy and sys.version_info < (3, 3),
75        ext_modules = [
76            Extension('genshi._speedups', ['genshi/_speedups.c']),
77        ],
78    )
79else:
80    speedups = None
81
82
83# Setuptools need some help figuring out if the egg is "zip_safe" or not
84if bdist_egg:
85    class my_bdist_egg(bdist_egg):
86        def zip_safe(self):
87            return not _speedup_available and bdist_egg.zip_safe(self)
88
89
90cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
91            'build_ext': optional_build_ext}
92if bdist_egg:
93    cmdclass['bdist_egg'] = my_bdist_egg
94
95
96# Use 2to3 if we're running under Python 3 (with Distribute)
97extra = {}
98if sys.version_info >= (3,):
99    extra['use_2to3'] = True
100    extra['convert_2to3_doctests'] = []
101    extra['use_2to3_fixers'] = ['fixes']
102    # Install genshi template tests
103    extra['include_package_data'] = True
104
105
106# include tests for python3 setup.py test (needed when creating
107# source distributions on python2 too so that they work on python3)
108packages = [
109    'genshi', 'genshi.filters', 'genshi.template',
110    'genshi.tests', 'genshi.filters.tests',
111    'genshi.template.tests',
112    'genshi.template.tests.templates',
113]
114
115
116setup(
117    name = 'Genshi',
118    version = '0.8',
119    description = 'A toolkit for generation of output for the web',
120    long_description = \
121"""Genshi is a Python library that provides an integrated set of
122components for parsing, generating, and processing HTML, XML or
123other textual content for output generation on the web. The major
124feature is a template language, which is heavily inspired by Kid.""",
125    author = 'Edgewall Software',
126    author_email = 'info@edgewall.org',
127    license = 'BSD',
128    url = 'http://genshi.edgewall.org/',
129    download_url = 'http://genshi.edgewall.org/wiki/Download',
130
131    classifiers = [
132        'Development Status :: 4 - Beta',
133        'Environment :: Web Environment',
134        'Intended Audience :: Developers',
135        'License :: OSI Approved :: BSD License',
136        'Operating System :: OS Independent',
137        'Programming Language :: Python',
138        'Programming Language :: Python :: 2',
139        'Programming Language :: Python :: 3',
140        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
141        'Topic :: Software Development :: Libraries :: Python Modules',
142        'Topic :: Text Processing :: Markup :: HTML',
143        'Topic :: Text Processing :: Markup :: XML'
144    ],
145    keywords = ['python.templating.engines'],
146    packages = packages,
147    test_suite = 'genshi.tests.suite',
148
149    extras_require = {
150        'i18n': ['Babel>=0.8'],
151        'plugin': ['setuptools>=0.6a2']
152    },
153    entry_points = """
154    [babel.extractors]
155    genshi = genshi.filters.i18n:extract[i18n]
156   
157    [python.templating.engines]
158    genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
159    genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
160    genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin]
161    """,
162
163    features = {'speedups': speedups},
164    cmdclass = cmdclass,
165
166    **extra
167)
Note: See TracBrowser for help on using the repository browser.