Mercurial > genshi > genshi-test
annotate setup.py @ 558:2a6cf641cb5e
Fix typo in i18n doc.
author | cmlenz |
---|---|
date | Tue, 03 Jul 2007 21:48:11 +0000 |
parents | 4a53763b3948 |
children | e0d57ab9b0be f0bb2c5ea0ff |
rev | line source |
---|---|
1 | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
3 # | |
66
822089ae65ce
Switch copyright to Edgewall and URLs to markup.edgewall.org.
cmlenz
parents:
27
diff
changeset
|
4 # Copyright (C) 2006 Edgewall Software |
1 | 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 | |
230 | 9 # are also available at http://genshi.edgewall.org/wiki/License. |
1 | 10 # |
11 # This software consists of voluntary contributions made by many | |
12 # individuals. For the exact contribution history, see the revision | |
230 | 13 # history and logs, available at http://genshi.edgewall.org/log/. |
1 | 14 |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
15 from distutils.cmd import Command |
541 | 16 from distutils.command.build_ext import build_ext |
17 from distutils.errors import CCompilerError | |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
18 import doctest |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
19 from glob import glob |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
20 import os |
84
894576e2b813
Make dependency of the setup script on setuptools optional.
cmlenz
parents:
66
diff
changeset
|
21 try: |
541 | 22 from setuptools import setup, Extension, Feature |
84
894576e2b813
Make dependency of the setup script on setuptools optional.
cmlenz
parents:
66
diff
changeset
|
23 except ImportError: |
541 | 24 from distutils.core import setup, Extension |
25 Feature = None | |
426 | 26 import sys |
1 | 27 |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
28 |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
29 class build_doc(Command): |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
30 description = 'Builds the documentation' |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
31 user_options = [ |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
32 ('force', None, |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
33 "force regeneration even if no reStructuredText files have changed"), |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
34 ('without-apidocs', None, |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
35 "whether to skip the generation of API documentaton"), |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
36 ] |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
37 boolean_options = ['force', 'without-apidocs'] |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
38 |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
39 def initialize_options(self): |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
40 self.force = False |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
41 self.without_apidocs = False |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
42 |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
43 def finalize_options(self): |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
44 pass |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
45 |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
46 def run(self): |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
47 from docutils.core import publish_cmdline |
508
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
48 from docutils.nodes import raw |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
49 from docutils.parsers import rst |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
50 |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
51 docutils_conf = os.path.join('doc', 'conf', 'docutils.ini') |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
52 epydoc_conf = os.path.join('doc', 'conf', 'epydoc.ini') |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
53 |
508
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
54 try: |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
55 from pygments import highlight |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
56 from pygments.lexers import get_lexer_by_name |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
57 from pygments.formatters import HtmlFormatter |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
58 |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
59 def code_block(name, arguments, options, content, lineno, |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
60 content_offset, block_text, state, state_machine): |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
61 lexer = get_lexer_by_name(arguments[0]) |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
62 html = highlight('\n'.join(content), lexer, HtmlFormatter()) |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
63 return [raw('', html, format='html')] |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
64 code_block.arguments = (1, 0, 0) |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
65 code_block.options = {'language' : rst.directives.unchanged} |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
66 code_block.content = 1 |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
67 rst.directives.register_directive('code-block', code_block) |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
68 except ImportError: |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
69 print 'Pygments not installed, syntax highlighting disabled' |
cabd80e75dad
Enable syntax highlighting (with Pygments) on doc page.
cmlenz
parents:
492
diff
changeset
|
70 |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
71 for source in glob('doc/*.txt'): |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
72 dest = os.path.splitext(source)[0] + '.html' |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
73 if self.force or not os.path.exists(dest) or \ |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
74 os.path.getmtime(dest) < os.path.getmtime(source): |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
75 print 'building documentation file %s' % dest |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
76 publish_cmdline(writer_name='html', |
426 | 77 argv=['--config=%s' % docutils_conf, source, |
78 dest]) | |
79 | |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
80 if not self.without_apidocs: |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
81 try: |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
82 from epydoc import cli |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
83 old_argv = sys.argv[1:] |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
84 sys.argv[1:] = [ |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
85 '--config=%s' % epydoc_conf, |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
86 '--no-private', # epydoc bug, not read from config |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
87 '--simple-term', |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
88 '--verbose' |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
89 ] |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
90 cli.cli() |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
91 sys.argv[1:] = old_argv |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
92 |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
93 except ImportError: |
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
94 print 'epydoc not installed, skipping API documentation.' |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
95 |
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
96 |
394 | 97 class test_doc(Command): |
98 description = 'Tests the code examples in the documentation' | |
99 user_options = [] | |
100 | |
101 def initialize_options(self): | |
102 pass | |
103 | |
104 def finalize_options(self): | |
105 pass | |
106 | |
107 def run(self): | |
108 for filename in glob('doc/*.txt'): | |
109 print 'testing documentation file %s' % filename | |
110 doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS) | |
111 | |
112 | |
541 | 113 class optional_build_ext(build_ext): |
114 # This class allows C extension building to fail. | |
115 def build_extension(self, ext): | |
116 try: | |
117 build_ext.build_extension(self, ext) | |
118 except CCompilerError, x: | |
119 print '*' * 70 | |
120 print """WARNING: | |
121 An optional C extension could not be compiled, speedups will not be | |
122 available.""" | |
123 print '*' * 70 | |
124 | |
125 | |
126 if Feature: | |
127 speedups = Feature( | |
128 "optionial C speed-enhancements", | |
129 standard = True, | |
130 ext_modules = [ | |
131 Extension('genshi._speedups', ['genshi/_speedups.c']), | |
132 ], | |
133 ) | |
134 else: | |
135 speedups = None | |
136 | |
1 | 137 setup( |
230 | 138 name = 'Genshi', |
455 | 139 version = '0.5', |
230 | 140 description = 'A toolkit for stream-based generation of output for the web', |
148
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
141 long_description = \ |
452 | 142 """Genshi is a Python library that provides an integrated set of |
143 components for parsing, generating, and processing HTML, XML or | |
144 other textual content for output generation on the web. The major | |
145 feature is a template language, which is heavily inspired by Kid.""", | |
148
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
146 author = 'Edgewall Software', |
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
147 author_email = 'info@edgewall.org', |
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
148 license = 'BSD', |
230 | 149 url = 'http://genshi.edgewall.org/', |
256 | 150 download_url = 'http://genshi.edgewall.org/wiki/Download', |
148
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
151 zip_safe = True, |
a0a52cf4e4de
Added changelog file, plus some README and setup tweaks.
cmlenz
parents:
145
diff
changeset
|
152 |
124
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
153 classifiers = [ |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
154 'Development Status :: 4 - Beta', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
155 'Environment :: Web Environment', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
156 'Intended Audience :: Developers', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
157 'License :: OSI Approved :: BSD License', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
158 'Operating System :: OS Independent', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
159 'Programming Language :: Python', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
160 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
161 'Topic :: Software Development :: Libraries :: Python Modules', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
162 'Topic :: Text Processing :: Markup :: HTML', |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
163 'Topic :: Text Processing :: Markup :: XML' |
9a2acebe84f7
Add Trove classifiers and download URL to `setup.py`.
cmlenz
parents:
84
diff
changeset
|
164 ], |
215 | 165 keywords = ['python.templating.engines'], |
452 | 166 packages = ['genshi', 'genshi.filters', 'genshi.template'], |
230 | 167 test_suite = 'genshi.tests.suite', |
84
894576e2b813
Make dependency of the setup script on setuptools optional.
cmlenz
parents:
66
diff
changeset
|
168 |
530 | 169 extras_require = { |
170 'i18n': ['Babel>=0.8'], | |
171 'plugin': ['setuptools>=0.6a2'] | |
172 }, | |
4
f8612f05af99
Added first stab of an implementation of the !TurboGears [http://www.turbogears.org/docs/plugins/template.html plugin API for template engines], and also a !TurboGears-based example using this plugin. Both written by Matt Good.
cmlenz
parents:
1
diff
changeset
|
173 entry_points = """ |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
174 [babel.extractors] |
530 | 175 genshi = genshi.filters.i18n:extract[i18n] |
528
f38ce008ab0a
Integrated [http://babel.edgewall.org/ Babel] message extraction plugin, and added I18n doc page.
cmlenz
parents:
508
diff
changeset
|
176 |
4
f8612f05af99
Added first stab of an implementation of the !TurboGears [http://www.turbogears.org/docs/plugins/template.html plugin API for template engines], and also a !TurboGears-based example using this plugin. Both written by Matt Good.
cmlenz
parents:
1
diff
changeset
|
177 [python.templating.engines] |
336
5f2c7782cd8a
Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
265
diff
changeset
|
178 genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] |
5f2c7782cd8a
Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
265
diff
changeset
|
179 genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin] |
5f2c7782cd8a
Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
265
diff
changeset
|
180 genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin] |
4
f8612f05af99
Added first stab of an implementation of the !TurboGears [http://www.turbogears.org/docs/plugins/template.html plugin API for template engines], and also a !TurboGears-based example using this plugin. Both written by Matt Good.
cmlenz
parents:
1
diff
changeset
|
181 """, |
382
d7da3fba7faf
* Added documentation for the various stream event kinds.
cmlenz
parents:
336
diff
changeset
|
182 |
541 | 183 features = {'speedups': speedups}, |
184 cmdclass = {'build_doc': build_doc, 'test_doc': test_doc, | |
185 'build_ext': optional_build_ext} | |
1 | 186 ) |