Add compile_grammar command to setup.py (ref: #2765)

This commit is contained in:
Takeshi KOMIYA 2016-08-19 20:16:02 +09:00
parent 05caa0f037
commit dbac9aa8ec
2 changed files with 27 additions and 5 deletions

View File

@ -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__,

View File

@ -9,6 +9,7 @@ Release checklist
* Update release date in CHANGES
* `git commit -am 'Bump to x.y.z final'`
* `make clean`
* `python setup.py compile_grammar`
* `python setup.py release bdist_wheel sdist upload --identity=[your key]`
* Check PyPI release page for obvious errors
* `git tag` with version number