RosettaCommons / binder

Binder, tool for automatic generation of Python bindings
MIT License
322 stars 66 forks source link

build.py didn't find python executable (solved) #246

Closed shakfu closed 3 weeks ago

shakfu commented 2 years ago

I just tried compile binder off a fresh clone on macOS Monterey (python3.10) and got an error after running python3 build.py where cmake couldn't find the python interpreter (which is weird since I used it to run build.py) and suggested to set -DPYTHON_EXECUTABLE.

I fixed it with a small change to build.py to include -DPYTHON_EXECUTABLE=`which python3` as follows:

$ git diff build.py
diff --git a/build.py b/build.py
index 6ac5db7..e5b4d15 100644
--- a/build.py
+++ b/build.py
@@ -180,7 +180,7 @@ def install_llvm_tool(name, source_location, prefix_root, debug, compiler, jobs,
         if not os.path.isdir(build_dir): os.makedirs(build_dir)
         execute(
             'Building tool: {}...'.format(name), # -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=1
-            'cd {build_dir} && cmake -G Ninja {config} -DLLVM_ENABLE_EH=1 -DLLVM_ENABLE_RTTI=ON {gcc_install_prefix} .. && ninja binder {headers} {jobs}'.format( # was 'binder clang', we need to build Clang so lib/clang/<version>/include is also built
+            'cd {build_dir} && cmake -G Ninja {config} -DPYTHON_EXECUTABLE=`which python3` -DLLVM_ENABLE_EH=1 -DLLVM_ENABLE_RTTI=ON {gcc_install_prefix} .. && ninja binder {headers} {jobs}'.format( # was 'binder clang', we need to build Clang so lib/clang/<version>/include is also built
                 build_dir=build_dir, config=config,
                 jobs=f'-j{jobs}' if jobs else '',
                 gcc_install_prefix='-DGCC_INSTALL_PREFIX='+gcc_install_prefix if gcc_install_prefix else '',
lyskov commented 2 years ago

Thank you for tracking this down @shakfu ! I will push this to master soon.