#!/usr/bin/python from setuptools import setup from distutils.core import Extension from distutils.command.build_ext import build_ext from subprocess import check_call class Build_WLP_ext(build_ext): def run(self): self.make_file('wlp/command.y', 'wlp/y.tab.c', check_call, ([['yacc', '-d', '-o', 'wlp/commands.tab.c', 'wlp/commands.y']]), 'Generating lexer') self.make_file('wlp/commands.l', 'wlp/lex.yy.c', check_call, ([['lex', '-o', 'wlp/lex.yy.c', 'wlp/commands.l']]), 'Generating parser') build_ext.run(self) # see https://github.com/Turbo87/py-xcsoar/blob/master/setup.py wlp_module = Extension('wlp', sources=['wlp/wlp.c', 'wlp/structs.c', 'wlp/commands.tab.c', 'wlp/lex.yy.c']) install_requirements = [''] setup(name='PackageName', version='1.0', description='This is a demo package', cmdclass={'build_ext': Build_WLP_ext}, ext_modules=[wlp_module], install_requires=install_requirements)