Reputation: 41
I have a C++ library I would like to bind to Python. I began using Pybindgen, and it is really easy to use, but manually adding functions and namespaces will take a long time considering the size of my C++ library. I've read through the documentation on PyBindGen, specifically, the gccxml portion that supposedly scans header files for me. This would be ideal, yet I can't get it to function properly. Just as a test, I inputted my main header file and tried to export it, but I get this error:
python bindinggenerator.py
Traceback (most recent call last):
File "bindinggenerator.py", line 16, in <module>
main()
File "bindinggenerator.py", line 9, in main
module = module_parser.parse("include\\PhospheneEngine.h")
File "C:\Users\paolo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pybindgen\gccxmlparser.py", line 598, in parse
pygen_classifier, gccxml_options)
File "C:\Users\paolo\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pybindgen\gccxmlparser.py", line 658, in parse_init
assert isinstance(header_files, list)
AssertionError
And of course my Python code is basically just the modified example from here.
import sys
import pybindgen
from pybindgen import FileCodeSink
from pybindgen.gccxmlparser import ModuleParser
def main():
module_parser = ModuleParser('PhospheneEngine', '::')
module = module_parser.parse("include\\PhospheneEngine.h")
module.add_include("'include\\PhospheneEngine.h'")
pybindgen.write_preamble(FileCodeSink(sys.stdout))
module.generate(FileCodeSink(sys.stdout))
if (__name__ == '__main__'):
main()
I have both gccxml installed and pygccxml (For Python 3.5) installed. The documentation really doesn't say too much about this process, so possibly a quick rundown of how to use this feature would be appreciated.
Thanks in advance.
Upvotes: 1
Views: 203
Reputation: 386
The parse function takes a list of headers.
module = module_parser.parse(["include\\PhospheneEngine.h"])
Upvotes: 1