diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-08-19 20:16:02 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-08-19 20:16:02 +0900 |
commit | dbac9aa8ec859b15b6844a1090df0b1b9bb38ab4 (patch) | |
tree | 2a303f44daa522ca6f014a5d936e802574239778 /setup.py | |
parent | 05caa0f0375c788a041d1fd47a174d56b255a131 (diff) | |
download | sphinx-git-dbac9aa8ec859b15b6844a1090df0b1b9bb38ab4.tar.gz |
Add compile_grammar command to setup.py (ref: #2765)
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -4,9 +4,9 @@ from setuptools import setup, find_packages import os import sys from distutils import log +from distutils.cmd import Command import sphinx -from sphinx.pycode.pgen2.driver import compile_grammar long_desc = ''' Sphinx is a tool that makes it easy to create intelligent and beautiful @@ -73,10 +73,6 @@ extras_require = { if sys.platform == 'win32': requires.append('colorama>=0.3.5') -# Compile grammars before packaging -compile_grammar('sphinx/pycode/Grammar-py2.txt') -compile_grammar('sphinx/pycode/Grammar-py3.txt') - # Provide a "compile_catalog" command that also creates the translated # JavaScript files if Babel is available. @@ -173,6 +169,31 @@ else: cmdclass['compile_catalog'] = compile_catalog_plusjs +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 + +cmdclass['compile_grammar'] = CompileGrammarCommand + + setup( name='Sphinx', version=sphinx.__version__, |