summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst4
-rw-r--r--setup.py23
2 files changed, 23 insertions, 4 deletions
diff --git a/README.rst b/README.rst
index 4d24638..5a4e637 100644
--- a/README.rst
+++ b/README.rst
@@ -96,10 +96,6 @@ favorite Python packaging/distribution tool, for example with::
> pip install pycparser
-It's recommended to run ``_build_tables.py`` in the **pycparser** code directory
-after installation to make sure the parsing tables are pre-generated. This can
-make your code run faster.
-
Known problems
--------------
diff --git a/setup.py b/setup.py
index 0801f6f..cb68cd7 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,27 @@
import os, sys
from distutils.core import setup
+from distutils.command.install import install as _install
+from distutils.command.sdist import sdist as _sdist
+
+
+def _run_build_tables(dir):
+ from subprocess import call
+ call([sys.executable, '_build_tables.py'],
+ cwd=os.path.join(dir, 'pycparser'))
+
+
+class install(_install):
+ def run(self):
+ _install.run(self)
+ self.execute(_run_build_tables, (self.install_lib,),
+ msg="Build the lexing/parsing tables")
+
+
+class sdist(_sdist):
+ def make_release_tree(self, basedir, files):
+ _sdist.make_release_tree(self, basedir, files)
+ self.execute(_run_build_tables, (basedir,),
+ msg="Build the lexing/parsing tables")
setup(
@@ -24,6 +46,7 @@ setup(
'Programming Language :: Python :: 3',],
packages=['pycparser', 'pycparser.ply'],
package_data={'pycparser': ['*.cfg']},
+ cmdclass={'install': install, 'sdist': sdist},
)