• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os, sys
2try:
3    from setuptools import setup
4    from setuptools.command.install import install as _install
5    from setuptools.command.sdist import sdist as _sdist
6except ImportError:
7    from distutils.core import setup
8    from distutils.command.install import install as _install
9    from distutils.command.sdist import sdist as _sdist
10
11
12def _run_build_tables(dir):
13    from subprocess import check_call
14    # This is run inside the install staging directory (that had no .pyc files)
15    # We don't want to generate any.
16    # https://github.com/eliben/pycparser/pull/135
17    check_call([sys.executable, '-B', '_build_tables.py'],
18               cwd=os.path.join(dir, 'pycparser'))
19
20
21class install(_install):
22    def run(self):
23        _install.run(self)
24        self.execute(_run_build_tables, (self.install_lib,),
25                     msg="Build the lexing/parsing tables")
26
27
28class sdist(_sdist):
29    def make_release_tree(self, basedir, files):
30        _sdist.make_release_tree(self, basedir, files)
31        self.execute(_run_build_tables, (basedir,),
32                     msg="Build the lexing/parsing tables")
33
34
35setup(
36    # metadata
37    name='pycparser',
38    description='C parser in Python',
39    long_description="""
40        pycparser is a complete parser of the C language, written in
41        pure Python using the PLY parsing library.
42        It parses C code into an AST and can serve as a front-end for
43        C compilers or analysis tools.
44    """,
45    license='BSD',
46    version='2.19',
47    author='Eli Bendersky',
48    maintainer='Eli Bendersky',
49    author_email='eliben@gmail.com',
50    url='https://github.com/eliben/pycparser',
51    platforms='Cross Platform',
52    classifiers = [
53        'Development Status :: 5 - Production/Stable',
54        'License :: OSI Approved :: BSD License',
55        'Programming Language :: Python :: 2',
56        'Programming Language :: Python :: 2.7',
57        'Programming Language :: Python :: 3',
58        'Programming Language :: Python :: 3.4',
59        'Programming Language :: Python :: 3.5',
60        'Programming Language :: Python :: 3.6',
61    ],
62    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
63    packages=['pycparser', 'pycparser.ply'],
64    package_data={'pycparser': ['*.cfg']},
65    cmdclass={'install': install, 'sdist': sdist},
66)
67