diff options
author | Florian Rathgeber <florian.rathgeber@gmail.com> | 2013-08-09 19:39:13 +0200 |
---|---|---|
committer | Florian Rathgeber <florian.rathgeber@gmail.com> | 2013-12-30 17:06:17 +0100 |
commit | aa47db488c2966c2c998abe8853f881bf8feb37e (patch) | |
tree | efd86ef5ff3e3946aa81fce80e5360f00e3c555d /setup.py | |
parent | 62a4d2a19aace9e0b99283c2edcac2a139fd73ac (diff) | |
download | pycparser-aa47db488c2966c2c998abe8853f881bf8feb37e.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
* Use setuptools if available, fall back to distutils if not
* 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.py | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1,5 +1,32 @@ import os, sys -from distutils.core import setup +try: + from setuptools import setup + from setuptools.command.install import install as _install + from setuptools.command.sdist import sdist as _sdist +except ImportError: + 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 +51,7 @@ setup( 'Programming Language :: Python :: 3',], packages=['pycparser', 'pycparser.ply'], package_data={'pycparser': ['*.cfg']}, + cmdclass={'install': install, 'sdist': sdist}, ) |