#! /usr/bin/env python import sys import os import pybindgen from pybindgen.typehandlers import base as typehandlers from pybindgen import (ReturnValue, Parameter, Module, Function, FileCodeSink) from pybindgen import (CppMethod, CppConstructor, CppClass, Enum) from pybindgen.gccxmlparser import ModuleParser from pybindgen.function import CustomFunctionWrapper from pybindgen.cppmethod import CustomCppMethodWrapper import foomodulegen_common def my_module_gen(): out = FileCodeSink(sys.stdout) pygen_file = open(sys.argv[3], "wt") module_parser = ModuleParser('foo2', '::') print >> sys.stderr, "PYTHON_INCLUDES:", repr(sys.argv[2]) gccxml_options = dict( include_paths=eval(sys.argv[2]), ) module = module_parser.parse([sys.argv[1]], includes=['"foo.h"'], pygen_sink=FileCodeSink(pygen_file), gccxml_options=gccxml_options) pygen_file.close() foomodulegen_common.customize_module(module) module.generate(out) def main(): if sys.argv[1] == '-d': del sys.argv[1] import pdb pdb.set_trace() my_module_gen() else: try: import cProfile as profile except ImportError: my_module_gen() else: print >> sys.stderr, "** running under profiler" profile.run('my_module_gen()', 'foomodulegen-auto.pstat') if __name__ == '__main__': main()