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
RevLine 
[2]1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
[1120]4# Copyright (C) 2006-2010 Edgewall Software
[2]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
[287]9# are also available at http://genshi.edgewall.org/wiki/License.
[2]10#
11# This software consists of voluntary contributions made by many
12# individuals. For the exact contribution history, see the revision
[287]13# history and logs, available at http://genshi.edgewall.org/log/.
[2]14
[464]15from distutils.cmd import Command
[650]16from distutils.command.build_ext import build_ext
[789]17from distutils.errors import CCompilerError, DistutilsPlatformError
[464]18import doctest
19from glob import glob
20import os
[89]21try:
[650]22    from setuptools import setup, Extension, Feature
[928]23    from setuptools.command.bdist_egg import bdist_egg
[89]24except ImportError:
[650]25    from distutils.core import setup, Extension
26    Feature = None
[928]27    bdist_egg = None
[518]28import sys
[2]29
[699]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
[464]35
[928]36_speedup_available = False
[464]37
[1179]38is_pypy = hasattr(sys, 'pypy_version_info')
[1120]39
[650]40class optional_build_ext(build_ext):
41    # This class allows C extension building to fail.
[789]42    def run(self):
43        try:
44            build_ext.run(self)
[1154]45        except DistutilsPlatformError:
46            _etype, e, _tb = sys.exc_info()
[995]47            self._unavailable(e)
[789]48
[650]49    def build_extension(self, ext):
50        try:
51            build_ext.build_extension(self, ext)
[928]52            global _speedup_available
53            _speedup_available = True
[1154]54        except CCompilerError:
55            _etype, e, _tb = sys.exc_info()
[995]56            self._unavailable(e)
[789]57
[995]58    def _unavailable(self, exc):
[1076]59        print('*' * 70)
60        print("""WARNING:
[650]61An optional C extension could not be compiled, speedups will not be
[1076]62available.""")
63        print('*' * 70)
64        print(exc)
[650]65
66
67if Feature:
[1247]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)
[650]72    speedups = Feature(
[1089]73        "optional C speed-enhancements",
[1247]74        standard = not is_pypy and sys.version_info < (3, 3),
[650]75        ext_modules = [
76            Extension('genshi._speedups', ['genshi/_speedups.c']),
77        ],
78    )
79else:
80    speedups = None
81
[928]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
[995]95
[1154]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
[1211]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
[2]116setup(
[287]117    name = 'Genshi',
[1209]118    version = '0.8',
[715]119    description = 'A toolkit for generation of output for the web',
[190]120    long_description = \
[546]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.""",
[190]125    author = 'Edgewall Software',
126    author_email = 'info@edgewall.org',
127    license = 'BSD',
[287]128    url = 'http://genshi.edgewall.org/',
[318]129    download_url = 'http://genshi.edgewall.org/wiki/Download',
[190]130
[156]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',
[1201]138        'Programming Language :: Python :: 2',
[1154]139        'Programming Language :: Python :: 3',
[156]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    ],
[271]145    keywords = ['python.templating.engines'],
[1154]146    packages = packages,
[287]147    test_suite = 'genshi.tests.suite',
[89]148
[636]149    extras_require = {
150        'i18n': ['Babel>=0.8'],
151        'plugin': ['setuptools>=0.6a2']
152    },
[5]153    entry_points = """
[634]154    [babel.extractors]
[636]155    genshi = genshi.filters.i18n:extract[i18n]
[634]156   
[5]157    [python.templating.engines]
[414]158    genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
159    genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
160    genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin]
[5]161    """,
[464]162
[650]163    features = {'speedups': speedups},
[1154]164    cmdclass = cmdclass,
165
166    **extra
[2]167)
Note: See TracBrowser for help on using the repository browser.