libigl-python-bindings icon indicating copy to clipboard operation
libigl-python-bindings copied to clipboard

How to run scripts/generate_bindings.py ?

Open alecjacobson opened this issue 3 years ago • 7 comments

The help says:

Syntax: scripts/generate_bindings.py <path_to_c++_files>

If I try:

python scripts/generate_bindings.py ~/Repos/libigl/include/igl/cotmatrix.h

I get this error

Collecting cpp files for parsing...
Parsing header files...
Traceback (most recent call last):
  File "scripts/generate_bindings.py", line 197, in <module>
    with open("headers.dat", 'rb') as fs:
FileNotFoundError: [Errno 2] No such file or directory: 'headers.dat'

alecjacobson avatar Feb 26 '22 00:02 alecjacobson

try setting load_headers = True to False

teseoch avatar Feb 26 '22 00:02 teseoch

Thanks! I also realized that the argument should be a path containing .h/.cpp files without a final /. So,

python scripts/generate_bindings.py ~/Repos/libigl/include/igl

but not

python scripts/generate_bindings.py ~/Repos/libigl/include/igl/

alecjacobson avatar Feb 26 '22 00:02 alecjacobson

ok... I think that script was built for internal usage :)

teseoch avatar Feb 26 '22 00:02 teseoch

Make sense. Is there another recommended way to make a new binding from scratch? Just copy-paste the documentation?

alecjacobson avatar Feb 26 '22 00:02 alecjacobson

i think we should fix the script, it is super useful :)

In particular add the ability to skip existing bindings

teseoch avatar Feb 26 '22 00:02 teseoch

Sounds good. I'm hoping to go after all the functions in the other libigl modules, so maybe time to freshen this script to also work with those.

alecjacobson avatar Feb 26 '22 00:02 alecjacobson

the script uses clang to generate the code. https://github.com/libigl/libigl-python-bindings/blob/master/scripts/parser.py

The reason of the headers.dat is that it requires time to compile each file and get the ast, while generating the code from the ast is quick. I dont think this feature is necessary anymore as the generation is now ok

teseoch avatar Feb 26 '22 00:02 teseoch