summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorFlorian Rathgeber <florian.rathgeber@gmail.com>2013-08-09 19:39:13 +0200
committerFlorian Rathgeber <florian.rathgeber@gmail.com>2013-12-28 12:17:55 +0100
commit441d5447e485388367fc08c94e5e35e9e2ac1ddc (patch)
treeec550cdd7e4261c00155d179b01c58c282a2108c /setup.py
parente6994ed5022974a316900a0d13edc60ca6f7850d (diff)
downloadpycparser-441d5447e485388367fc08c94e5e35e9e2ac1ddc.tar.gz
Run post install task executing _build_tables
* Add post install task executing _build_tables in install destination * Use distutils execute for building tables to respect dry_run flag * Name the overriden class install to get the right help text * Also run _build_tables when creating a source distribution * No more need to run _build_tables.py manually Closes #5
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py23
1 files changed, 23 insertions, 0 deletions
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},
)