| 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 | |
|---|
| 15 | from distutils.cmd import Command |
|---|
| 16 | from distutils.command.build_ext import build_ext |
|---|
| 17 | from distutils.errors import CCompilerError, DistutilsPlatformError |
|---|
| 18 | import doctest |
|---|
| 19 | from glob import glob |
|---|
| 20 | import os |
|---|
| 21 | try: |
|---|
| 22 | from setuptools import setup, Extension, Feature |
|---|
| 23 | from setuptools.command.bdist_egg import bdist_egg |
|---|
| 24 | except ImportError: |
|---|
| 25 | from distutils.core import setup, Extension |
|---|
| 26 | Feature = None |
|---|
| 27 | bdist_egg = None |
|---|
| 28 | import sys |
|---|
| 29 | |
|---|
| 30 | sys.path.append(os.path.join('doc', 'common')) |
|---|
| 31 | try: |
|---|
| 32 | from doctools import build_doc, test_doc |
|---|
| 33 | except ImportError: |
|---|
| 34 | build_doc = test_doc = None |
|---|
| 35 | |
|---|
| 36 | _speedup_available = False |
|---|
| 37 | |
|---|
| 38 | is_pypy = hasattr(sys, 'pypy_version_info') |
|---|
| 39 | |
|---|
| 40 | class 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: |
|---|
| 61 | An optional C extension could not be compiled, speedups will not be |
|---|
| 62 | available.""") |
|---|
| 63 | print('*' * 70) |
|---|
| 64 | print(exc) |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | if Feature: |
|---|
| 68 | speedups = Feature( |
|---|
| 69 | "optional C speed-enhancements", |
|---|
| 70 | standard = not is_pypy, |
|---|
| 71 | ext_modules = [ |
|---|
| 72 | Extension('genshi._speedups', ['genshi/_speedups.c']), |
|---|
| 73 | ], |
|---|
| 74 | ) |
|---|
| 75 | else: |
|---|
| 76 | speedups = None |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | # Setuptools need some help figuring out if the egg is "zip_safe" or not |
|---|
| 80 | if bdist_egg: |
|---|
| 81 | class my_bdist_egg(bdist_egg): |
|---|
| 82 | def zip_safe(self): |
|---|
| 83 | return not _speedup_available and bdist_egg.zip_safe(self) |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | cmdclass = {'build_doc': build_doc, 'test_doc': test_doc, |
|---|
| 87 | 'build_ext': optional_build_ext} |
|---|
| 88 | if bdist_egg: |
|---|
| 89 | cmdclass['bdist_egg'] = my_bdist_egg |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | # Use 2to3 if we're running under Python 3 (with Distribute) |
|---|
| 93 | extra = {} |
|---|
| 94 | if sys.version_info >= (3,): |
|---|
| 95 | extra['use_2to3'] = True |
|---|
| 96 | extra['convert_2to3_doctests'] = [] |
|---|
| 97 | extra['use_2to3_fixers'] = ['fixes'] |
|---|
| 98 | # Install genshi template tests |
|---|
| 99 | extra['include_package_data'] = True |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | # include tests for python3 setup.py test (needed when creating |
|---|
| 103 | # source distributions on python2 too so that they work on python3) |
|---|
| 104 | packages = [ |
|---|
| 105 | 'genshi', 'genshi.filters', 'genshi.template', |
|---|
| 106 | 'genshi.tests', 'genshi.filters.tests', |
|---|
| 107 | 'genshi.template.tests', |
|---|
| 108 | 'genshi.template.tests.templates', |
|---|
| 109 | ] |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | setup( |
|---|
| 113 | name = 'Genshi', |
|---|
| 114 | version = '0.7', |
|---|
| 115 | description = 'A toolkit for generation of output for the web', |
|---|
| 116 | long_description = \ |
|---|
| 117 | """Genshi is a Python library that provides an integrated set of |
|---|
| 118 | components for parsing, generating, and processing HTML, XML or |
|---|
| 119 | other textual content for output generation on the web. The major |
|---|
| 120 | feature is a template language, which is heavily inspired by Kid.""", |
|---|
| 121 | author = 'Edgewall Software', |
|---|
| 122 | author_email = 'info@edgewall.org', |
|---|
| 123 | license = 'BSD', |
|---|
| 124 | url = 'http://genshi.edgewall.org/', |
|---|
| 125 | download_url = 'http://genshi.edgewall.org/wiki/Download', |
|---|
| 126 | |
|---|
| 127 | classifiers = [ |
|---|
| 128 | 'Development Status :: 4 - Beta', |
|---|
| 129 | 'Environment :: Web Environment', |
|---|
| 130 | 'Intended Audience :: Developers', |
|---|
| 131 | 'License :: OSI Approved :: BSD License', |
|---|
| 132 | 'Operating System :: OS Independent', |
|---|
| 133 | 'Programming Language :: Python', |
|---|
| 134 | 'Programming Language :: Python :: 2', |
|---|
| 135 | 'Programming Language :: Python :: 3', |
|---|
| 136 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', |
|---|
| 137 | 'Topic :: Software Development :: Libraries :: Python Modules', |
|---|
| 138 | 'Topic :: Text Processing :: Markup :: HTML', |
|---|
| 139 | 'Topic :: Text Processing :: Markup :: XML' |
|---|
| 140 | ], |
|---|
| 141 | keywords = ['python.templating.engines'], |
|---|
| 142 | packages = packages, |
|---|
| 143 | test_suite = 'genshi.tests.suite', |
|---|
| 144 | |
|---|
| 145 | extras_require = { |
|---|
| 146 | 'i18n': ['Babel>=0.8'], |
|---|
| 147 | 'plugin': ['setuptools>=0.6a2'] |
|---|
| 148 | }, |
|---|
| 149 | entry_points = """ |
|---|
| 150 | [babel.extractors] |
|---|
| 151 | genshi = genshi.filters.i18n:extract[i18n] |
|---|
| 152 | |
|---|
| 153 | [python.templating.engines] |
|---|
| 154 | genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] |
|---|
| 155 | genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] |
|---|
| 156 | genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin] |
|---|
| 157 | """, |
|---|
| 158 | |
|---|
| 159 | features = {'speedups': speedups}, |
|---|
| 160 | cmdclass = cmdclass, |
|---|
| 161 | |
|---|
| 162 | **extra |
|---|
| 163 | ) |
|---|