2009-10-22 18:07:31 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-02-13 10:14:16 -05:00
|
|
|
from setuptools import setup, find_packages
|
2008-02-09 23:09:36 +00:00
|
|
|
|
2008-09-06 17:36:25 +00:00
|
|
|
import os
|
2008-03-25 11:01:28 +00:00
|
|
|
import sys
|
2008-09-06 17:39:32 +00:00
|
|
|
from distutils import log
|
2016-08-19 20:16:02 +09:00
|
|
|
from distutils.cmd import Command
|
2008-02-09 23:09:36 +00:00
|
|
|
|
2008-03-25 11:01:28 +00:00
|
|
|
import sphinx
|
|
|
|
|
|
2017-10-21 15:20:21 +01:00
|
|
|
with open('README.rst') as f:
|
|
|
|
|
long_desc = f.read()
|
2008-03-18 19:37:05 +00:00
|
|
|
|
2016-09-02 01:19:47 +09:00
|
|
|
if sys.version_info < (2, 7) or (3, 0) <= sys.version_info < (3, 4):
|
|
|
|
|
print('ERROR: Sphinx requires at least Python 2.7 or 3.4 to run.')
|
2013-12-15 14:16:53 +09:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
2014-05-27 23:17:36 +09:00
|
|
|
requires = [
|
2016-08-18 09:34:43 +02:00
|
|
|
'six>=1.5',
|
2014-08-03 16:22:08 +09:00
|
|
|
'Jinja2>=2.3',
|
2015-01-01 19:02:19 +01:00
|
|
|
'Pygments>=2.0',
|
|
|
|
|
'docutils>=0.11',
|
2014-08-03 16:22:08 +09:00
|
|
|
'snowballstemmer>=1.1',
|
2015-09-13 09:37:41 +09:00
|
|
|
'babel>=1.3,!=2.0',
|
2015-03-07 07:35:04 -08:00
|
|
|
'alabaster>=0.7,<0.8',
|
2016-02-08 21:12:35 +09:00
|
|
|
'imagesize',
|
2017-01-29 13:15:49 +09:00
|
|
|
'requests>=2.0.0',
|
2017-04-10 13:08:14 +02:00
|
|
|
'setuptools',
|
2018-01-08 11:59:50 +09:00
|
|
|
'packaging',
|
2017-05-03 22:58:30 +09:00
|
|
|
'sphinxcontrib-websupport',
|
2014-05-27 23:17:36 +09:00
|
|
|
]
|
2017-05-23 09:33:45 +02:00
|
|
|
|
2014-12-13 18:34:55 +09:00
|
|
|
extras_require = {
|
|
|
|
|
# Environment Marker works for wheel 0.24 or later
|
|
|
|
|
':sys_platform=="win32"': [
|
2016-01-06 07:27:34 +09:00
|
|
|
'colorama>=0.3.5',
|
2014-12-13 18:34:55 +09:00
|
|
|
],
|
2017-05-26 00:12:45 +09:00
|
|
|
':python_version<"3.5"': [
|
|
|
|
|
'typing'
|
|
|
|
|
],
|
2017-04-29 15:22:34 +09:00
|
|
|
'websupport': [
|
2017-05-03 22:58:30 +09:00
|
|
|
'sqlalchemy>=0.9',
|
|
|
|
|
'whoosh>=2.0',
|
2017-04-29 15:22:34 +09:00
|
|
|
],
|
2015-03-07 16:29:29 +09:00
|
|
|
'test': [
|
2017-12-13 19:57:24 +00:00
|
|
|
'mock',
|
2017-02-26 15:31:21 +03:00
|
|
|
'pytest',
|
2017-10-03 09:46:28 +01:00
|
|
|
'pytest-cov',
|
2016-05-28 02:51:21 -04:00
|
|
|
'html5lib',
|
2017-10-21 12:19:04 +01:00
|
|
|
'flake8',
|
2015-03-07 16:29:29 +09:00
|
|
|
],
|
2017-10-03 09:46:28 +01:00
|
|
|
'test:python_version<"3"': [
|
|
|
|
|
'enum34',
|
|
|
|
|
],
|
|
|
|
|
'test:python_version>="3"': [
|
|
|
|
|
'mypy',
|
|
|
|
|
'typed_ast',
|
|
|
|
|
],
|
2014-12-13 18:34:55 +09:00
|
|
|
}
|
2012-11-03 12:29:55 -05:00
|
|
|
|
2008-09-06 17:36:25 +00:00
|
|
|
# Provide a "compile_catalog" command that also creates the translated
|
|
|
|
|
# JavaScript files if Babel is available.
|
|
|
|
|
|
2008-09-09 21:23:57 +00:00
|
|
|
cmdclass = {}
|
|
|
|
|
|
2008-09-06 17:36:25 +00:00
|
|
|
try:
|
|
|
|
|
from babel.messages.pofile import read_po
|
|
|
|
|
from babel.messages.frontend import compile_catalog
|
2017-10-03 09:46:28 +01:00
|
|
|
from json import dump
|
2008-09-06 17:36:25 +00:00
|
|
|
except ImportError:
|
2008-09-09 21:19:11 +00:00
|
|
|
pass
|
2008-09-06 17:36:25 +00:00
|
|
|
else:
|
|
|
|
|
class compile_catalog_plusjs(compile_catalog):
|
|
|
|
|
"""
|
|
|
|
|
An extended command that writes all message strings that occur in
|
|
|
|
|
JavaScript files to a JavaScript file along with the .mo file.
|
|
|
|
|
|
|
|
|
|
Unfortunately, babel's setup command isn't built very extensible, so
|
|
|
|
|
most of the run() code is duplicated here.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
compile_catalog.run(self)
|
|
|
|
|
|
2016-05-17 15:43:59 +03:00
|
|
|
if isinstance(self.domain, list):
|
|
|
|
|
for domain in self.domain:
|
|
|
|
|
self._run_domain_js(domain)
|
|
|
|
|
else:
|
|
|
|
|
self._run_domain_js(self.domain)
|
|
|
|
|
|
|
|
|
|
def _run_domain_js(self, domain):
|
2008-09-06 17:36:25 +00:00
|
|
|
po_files = []
|
|
|
|
|
js_files = []
|
|
|
|
|
|
|
|
|
|
if not self.input_file:
|
|
|
|
|
if self.locale:
|
|
|
|
|
po_files.append((self.locale,
|
|
|
|
|
os.path.join(self.directory, self.locale,
|
|
|
|
|
'LC_MESSAGES',
|
2016-05-17 15:43:59 +03:00
|
|
|
domain + '.po')))
|
2008-09-06 17:36:25 +00:00
|
|
|
js_files.append(os.path.join(self.directory, self.locale,
|
|
|
|
|
'LC_MESSAGES',
|
2016-05-17 15:43:59 +03:00
|
|
|
domain + '.js'))
|
2008-09-06 17:36:25 +00:00
|
|
|
else:
|
|
|
|
|
for locale in os.listdir(self.directory):
|
|
|
|
|
po_file = os.path.join(self.directory, locale,
|
2009-01-10 22:18:18 +01:00
|
|
|
'LC_MESSAGES',
|
2016-05-17 15:43:59 +03:00
|
|
|
domain + '.po')
|
2008-09-06 17:36:25 +00:00
|
|
|
if os.path.exists(po_file):
|
|
|
|
|
po_files.append((locale, po_file))
|
|
|
|
|
js_files.append(os.path.join(self.directory, locale,
|
|
|
|
|
'LC_MESSAGES',
|
2016-05-17 15:43:59 +03:00
|
|
|
domain + '.js'))
|
2008-09-06 17:36:25 +00:00
|
|
|
else:
|
|
|
|
|
po_files.append((self.locale, self.input_file))
|
|
|
|
|
if self.output_file:
|
|
|
|
|
js_files.append(self.output_file)
|
|
|
|
|
else:
|
|
|
|
|
js_files.append(os.path.join(self.directory, self.locale,
|
|
|
|
|
'LC_MESSAGES',
|
2016-05-17 15:43:59 +03:00
|
|
|
domain + '.js'))
|
2008-09-06 17:36:25 +00:00
|
|
|
|
|
|
|
|
for js_file, (locale, po_file) in zip(js_files, po_files):
|
2016-07-07 18:53:34 +03:00
|
|
|
with open(po_file, 'r') as infile:
|
2008-09-06 17:36:25 +00:00
|
|
|
catalog = read_po(infile, locale)
|
|
|
|
|
|
|
|
|
|
if catalog.fuzzy and not self.use_fuzzy:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
log.info('writing JavaScript strings in catalog %r to %r',
|
|
|
|
|
po_file, js_file)
|
|
|
|
|
|
|
|
|
|
jscatalog = {}
|
|
|
|
|
for message in catalog:
|
2014-09-01 23:16:54 +09:00
|
|
|
if any(x[0].endswith(('.js', '.js_t', '.html'))
|
|
|
|
|
for x in message.locations):
|
2008-09-06 17:36:25 +00:00
|
|
|
msgid = message.id
|
|
|
|
|
if isinstance(msgid, (list, tuple)):
|
|
|
|
|
msgid = msgid[0]
|
|
|
|
|
jscatalog[msgid] = message.string
|
|
|
|
|
|
2016-12-04 22:03:25 +09:00
|
|
|
with open(js_file, 'wt') as outfile:
|
2015-03-08 17:15:54 +01:00
|
|
|
outfile.write('Documentation.addTranslations(')
|
2008-09-06 17:36:25 +00:00
|
|
|
dump(dict(
|
|
|
|
|
messages=jscatalog,
|
|
|
|
|
plural_expr=catalog.plural_expr,
|
|
|
|
|
locale=str(catalog.locale)
|
2015-08-19 20:38:23 +02:00
|
|
|
), outfile, sort_keys=True)
|
2008-09-06 17:36:25 +00:00
|
|
|
outfile.write(');')
|
|
|
|
|
|
2008-09-09 21:19:11 +00:00
|
|
|
cmdclass['compile_catalog'] = compile_catalog_plusjs
|
2008-09-06 17:36:25 +00:00
|
|
|
|
|
|
|
|
|
2016-08-19 20:16:02 +09:00
|
|
|
class CompileGrammarCommand(Command):
|
|
|
|
|
description = 'Compile python grammar file for pycode'
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
from sphinx.pycode.pgen2.driver import compile_grammar
|
|
|
|
|
|
|
|
|
|
compile_grammar('sphinx/pycode/Grammar-py2.txt')
|
|
|
|
|
print('sphinx/pycode/Grammar-py2.txt ... done')
|
|
|
|
|
|
|
|
|
|
compile_grammar('sphinx/pycode/Grammar-py3.txt')
|
|
|
|
|
print('sphinx/pycode/Grammar-py3.txt ... done')
|
|
|
|
|
|
|
|
|
|
def sub_commands(self):
|
|
|
|
|
pass
|
|
|
|
|
|
2016-11-16 12:02:40 +09:00
|
|
|
|
2016-08-19 20:16:02 +09:00
|
|
|
cmdclass['compile_grammar'] = CompileGrammarCommand
|
|
|
|
|
|
|
|
|
|
|
2008-02-09 23:09:36 +00:00
|
|
|
setup(
|
|
|
|
|
name='Sphinx',
|
|
|
|
|
version=sphinx.__version__,
|
2012-11-04 11:28:12 +01:00
|
|
|
url='http://sphinx-doc.org/',
|
2015-02-28 01:10:03 +09:00
|
|
|
download_url='https://pypi.python.org/pypi/Sphinx',
|
2008-02-09 23:09:36 +00:00
|
|
|
license='BSD',
|
|
|
|
|
author='Georg Brandl',
|
|
|
|
|
author_email='georg@python.org',
|
|
|
|
|
description='Python documentation generator',
|
2008-03-18 19:37:05 +00:00
|
|
|
long_description=long_desc,
|
2008-02-09 23:09:36 +00:00
|
|
|
zip_safe=False,
|
2008-03-21 17:20:09 +00:00
|
|
|
classifiers=[
|
2010-05-25 01:08:52 +02:00
|
|
|
'Development Status :: 5 - Production/Stable',
|
2008-02-09 23:09:36 +00:00
|
|
|
'Environment :: Console',
|
|
|
|
|
'Environment :: Web Environment',
|
|
|
|
|
'Intended Audience :: Developers',
|
2010-05-25 01:08:52 +02:00
|
|
|
'Intended Audience :: Education',
|
2008-02-09 23:09:36 +00:00
|
|
|
'License :: OSI Approved :: BSD License',
|
|
|
|
|
'Operating System :: OS Independent',
|
|
|
|
|
'Programming Language :: Python',
|
2010-07-23 12:42:03 +01:00
|
|
|
'Programming Language :: Python :: 2',
|
2017-10-11 17:16:15 +03:00
|
|
|
'Programming Language :: Python :: 2.7',
|
2011-10-09 23:25:40 +02:00
|
|
|
'Programming Language :: Python :: 3',
|
2017-10-11 17:16:15 +03:00
|
|
|
'Programming Language :: Python :: 3.4',
|
|
|
|
|
'Programming Language :: Python :: 3.5',
|
|
|
|
|
'Programming Language :: Python :: 3.6',
|
|
|
|
|
'Programming Language :: Python :: Implementation :: CPython',
|
|
|
|
|
'Programming Language :: Python :: Implementation :: PyPy',
|
2014-11-27 09:58:53 +09:00
|
|
|
'Framework :: Sphinx',
|
|
|
|
|
'Framework :: Sphinx :: Extension',
|
|
|
|
|
'Framework :: Sphinx :: Theme',
|
2008-02-09 23:09:36 +00:00
|
|
|
'Topic :: Documentation',
|
2014-11-27 09:58:53 +09:00
|
|
|
'Topic :: Documentation :: Sphinx',
|
2010-05-25 01:08:52 +02:00
|
|
|
'Topic :: Text Processing',
|
2008-02-09 23:09:36 +00:00
|
|
|
'Topic :: Utilities',
|
|
|
|
|
],
|
|
|
|
|
platforms='any',
|
2015-01-06 22:26:56 +09:00
|
|
|
packages=find_packages(exclude=['tests']),
|
2008-02-09 23:09:36 +00:00
|
|
|
include_package_data=True,
|
|
|
|
|
entry_points={
|
|
|
|
|
'console_scripts': [
|
2017-09-21 10:28:44 +01:00
|
|
|
'sphinx-build = sphinx.cmd.build:main',
|
2017-10-01 14:45:41 +01:00
|
|
|
'sphinx-quickstart = sphinx.cmd.quickstart:main',
|
2017-07-11 16:24:07 +01:00
|
|
|
'sphinx-apidoc = sphinx.ext.apidoc:main',
|
2008-11-04 11:07:58 -07:00
|
|
|
'sphinx-autogen = sphinx.ext.autosummary.generate:main',
|
2008-07-29 09:51:58 +00:00
|
|
|
],
|
|
|
|
|
'distutils.commands': [
|
|
|
|
|
'build_sphinx = sphinx.setup_command:BuildDoc',
|
|
|
|
|
],
|
2017-10-01 21:57:23 +01:00
|
|
|
# consider moving this to 'flake8:local-plugins' once flake8 3.5.0 is
|
|
|
|
|
# in the wild:
|
|
|
|
|
# http://flake8.pycqa.org/en/latest/user/configuration.html\
|
|
|
|
|
# #using-local-plugins
|
|
|
|
|
'flake8.extension': [
|
|
|
|
|
'X101 = utils.checks:sphinx_has_header',
|
|
|
|
|
],
|
2008-02-09 23:09:36 +00:00
|
|
|
},
|
2008-03-25 11:01:28 +00:00
|
|
|
install_requires=requires,
|
2014-12-13 18:34:55 +09:00
|
|
|
extras_require=extras_require,
|
2008-09-06 17:36:25 +00:00
|
|
|
cmdclass=cmdclass,
|
2008-02-09 23:09:36 +00:00
|
|
|
)
|