cmlenz@1: #!/usr/bin/env python cmlenz@1: # -*- coding: utf-8 -*- cmlenz@1: # cmlenz@66: # Copyright (C) 2006 Edgewall Software cmlenz@1: # All rights reserved. cmlenz@1: # cmlenz@1: # This software is licensed as described in the file COPYING, which cmlenz@1: # you should have received as part of this distribution. The terms cmlenz@230: # are also available at http://genshi.edgewall.org/wiki/License. cmlenz@1: # cmlenz@1: # This software consists of voluntary contributions made by many cmlenz@1: # individuals. For the exact contribution history, see the revision cmlenz@230: # history and logs, available at http://genshi.edgewall.org/log/. cmlenz@1: cmlenz@382: from distutils.cmd import Command cmlenz@541: from distutils.command.build_ext import build_ext cmlenz@541: from distutils.errors import CCompilerError cmlenz@382: import doctest cmlenz@382: from glob import glob cmlenz@382: import os cmlenz@84: try: cmlenz@541: from setuptools import setup, Extension, Feature cmlenz@84: except ImportError: cmlenz@541: from distutils.core import setup, Extension cmlenz@541: Feature = None cmlenz@426: import sys cmlenz@1: cmlenz@382: cmlenz@382: class build_doc(Command): cmlenz@382: description = 'Builds the documentation' cmlenz@528: user_options = [ cmlenz@528: ('force', None, cmlenz@528: "force regeneration even if no reStructuredText files have changed"), cmlenz@528: ('without-apidocs', None, cmlenz@528: "whether to skip the generation of API documentaton"), cmlenz@528: ] cmlenz@528: boolean_options = ['force', 'without-apidocs'] cmlenz@382: cmlenz@382: def initialize_options(self): cmlenz@528: self.force = False cmlenz@528: self.without_apidocs = False cmlenz@382: cmlenz@382: def finalize_options(self): cmlenz@382: pass cmlenz@382: cmlenz@382: def run(self): cmlenz@382: from docutils.core import publish_cmdline cmlenz@508: from docutils.nodes import raw cmlenz@508: from docutils.parsers import rst cmlenz@508: cmlenz@528: docutils_conf = os.path.join('doc', 'conf', 'docutils.ini') cmlenz@528: epydoc_conf = os.path.join('doc', 'conf', 'epydoc.ini') cmlenz@382: cmlenz@508: try: cmlenz@508: from pygments import highlight cmlenz@508: from pygments.lexers import get_lexer_by_name cmlenz@508: from pygments.formatters import HtmlFormatter cmlenz@508: cmlenz@508: def code_block(name, arguments, options, content, lineno, cmlenz@508: content_offset, block_text, state, state_machine): cmlenz@508: lexer = get_lexer_by_name(arguments[0]) cmlenz@508: html = highlight('\n'.join(content), lexer, HtmlFormatter()) cmlenz@508: return [raw('', html, format='html')] cmlenz@508: code_block.arguments = (1, 0, 0) cmlenz@508: code_block.options = {'language' : rst.directives.unchanged} cmlenz@508: code_block.content = 1 cmlenz@508: rst.directives.register_directive('code-block', code_block) cmlenz@508: except ImportError: cmlenz@508: print 'Pygments not installed, syntax highlighting disabled' cmlenz@508: cmlenz@382: for source in glob('doc/*.txt'): cmlenz@382: dest = os.path.splitext(source)[0] + '.html' cmlenz@528: if self.force or not os.path.exists(dest) or \ cmlenz@528: os.path.getmtime(dest) < os.path.getmtime(source): cmlenz@382: print 'building documentation file %s' % dest cmlenz@382: publish_cmdline(writer_name='html', cmlenz@426: argv=['--config=%s' % docutils_conf, source, cmlenz@426: dest]) cmlenz@426: cmlenz@528: if not self.without_apidocs: cmlenz@528: try: cmlenz@528: from epydoc import cli cmlenz@528: old_argv = sys.argv[1:] cmlenz@528: sys.argv[1:] = [ cmlenz@528: '--config=%s' % epydoc_conf, cmlenz@528: '--no-private', # epydoc bug, not read from config cmlenz@528: '--simple-term', cmlenz@528: '--verbose' cmlenz@528: ] cmlenz@528: cli.cli() cmlenz@528: sys.argv[1:] = old_argv cmlenz@528: cmlenz@528: except ImportError: cmlenz@528: print 'epydoc not installed, skipping API documentation.' cmlenz@382: cmlenz@382: cmlenz@394: class test_doc(Command): cmlenz@394: description = 'Tests the code examples in the documentation' cmlenz@394: user_options = [] cmlenz@394: cmlenz@394: def initialize_options(self): cmlenz@394: pass cmlenz@394: cmlenz@394: def finalize_options(self): cmlenz@394: pass cmlenz@394: cmlenz@394: def run(self): cmlenz@394: for filename in glob('doc/*.txt'): cmlenz@394: print 'testing documentation file %s' % filename cmlenz@394: doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS) cmlenz@394: cmlenz@394: cmlenz@541: class optional_build_ext(build_ext): cmlenz@541: # This class allows C extension building to fail. cmlenz@541: def build_extension(self, ext): cmlenz@541: try: cmlenz@541: build_ext.build_extension(self, ext) cmlenz@541: except CCompilerError, x: cmlenz@541: print '*' * 70 cmlenz@541: print """WARNING: cmlenz@541: An optional C extension could not be compiled, speedups will not be cmlenz@541: available.""" cmlenz@541: print '*' * 70 cmlenz@541: cmlenz@541: cmlenz@541: if Feature: cmlenz@541: speedups = Feature( cmlenz@541: "optionial C speed-enhancements", cmlenz@541: standard = True, cmlenz@541: ext_modules = [ cmlenz@541: Extension('genshi._speedups', ['genshi/_speedups.c']), cmlenz@541: ], cmlenz@541: ) cmlenz@541: else: cmlenz@541: speedups = None cmlenz@541: cmlenz@1: setup( cmlenz@230: name = 'Genshi', cmlenz@455: version = '0.5', cmlenz@230: description = 'A toolkit for stream-based generation of output for the web', cmlenz@148: long_description = \ cmlenz@452: """Genshi is a Python library that provides an integrated set of cmlenz@452: components for parsing, generating, and processing HTML, XML or cmlenz@452: other textual content for output generation on the web. The major cmlenz@452: feature is a template language, which is heavily inspired by Kid.""", cmlenz@148: author = 'Edgewall Software', cmlenz@148: author_email = 'info@edgewall.org', cmlenz@148: license = 'BSD', cmlenz@230: url = 'http://genshi.edgewall.org/', cmlenz@256: download_url = 'http://genshi.edgewall.org/wiki/Download', cmlenz@148: zip_safe = True, cmlenz@148: cmlenz@124: classifiers = [ cmlenz@124: 'Development Status :: 4 - Beta', cmlenz@124: 'Environment :: Web Environment', cmlenz@124: 'Intended Audience :: Developers', cmlenz@124: 'License :: OSI Approved :: BSD License', cmlenz@124: 'Operating System :: OS Independent', cmlenz@124: 'Programming Language :: Python', cmlenz@124: 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', cmlenz@124: 'Topic :: Software Development :: Libraries :: Python Modules', cmlenz@124: 'Topic :: Text Processing :: Markup :: HTML', cmlenz@124: 'Topic :: Text Processing :: Markup :: XML' cmlenz@124: ], cmlenz@215: keywords = ['python.templating.engines'], cmlenz@452: packages = ['genshi', 'genshi.filters', 'genshi.template'], cmlenz@230: test_suite = 'genshi.tests.suite', cmlenz@84: cmlenz@530: extras_require = { cmlenz@530: 'i18n': ['Babel>=0.8'], cmlenz@530: 'plugin': ['setuptools>=0.6a2'] cmlenz@530: }, cmlenz@4: entry_points = """ cmlenz@528: [babel.extractors] cmlenz@530: genshi = genshi.filters.i18n:extract[i18n] cmlenz@528: cmlenz@4: [python.templating.engines] cmlenz@336: genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] cmlenz@336: genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] cmlenz@336: genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin] cmlenz@4: """, cmlenz@382: cmlenz@541: features = {'speedups': speedups}, cmlenz@541: cmdclass = {'build_doc': build_doc, 'test_doc': test_doc, cmlenz@541: 'build_ext': optional_build_ext} cmlenz@1: )