23
23
python_module_name = 'bdsg'
24
24
25
25
# We have one global notion of what an include looks like
26
- INCLUDE_REGEX = re .compile ('^\s*#include\s+(["<])(.*)([">])' )
26
+ INCLUDE_REGEX = re .compile (r '^\s*#include\s+(["<])(.*)([">])' )
27
27
# We have one master list of source code extensions
28
28
SOURCE_EXTENSIONS = ['hpp' , 'cpp' , 'h' , 'cc' , 'c' ]
29
29
30
30
def clone_repos ():
31
- ''' download the most recent copy of binder from git '''
31
+ ''' download the most correct binder and pybind11 from git '''
32
32
if not glob .glob ("binder" ):
33
33
print ("Binder not found, cloning repo..." )
34
- subprocess .check_call (['git' , 'clone' , 'https://github.com/RosettaCommons /binder.git' , 'binder' ])
34
+ subprocess .check_call (['git' , 'clone' , 'https://github.com/adamnovak /binder.git' , 'binder' ])
35
35
parent = os .getcwd ()
36
36
os .chdir ('binder' )
37
- subprocess .check_call (['git' , 'checkout' , 'ee2ecff151d125c3add072a7765aebad6f42a70d' ])
37
+ # See also: Binder commit defined in CMakeLists.txt for header files.
38
+ subprocess .check_call (['git' , 'checkout' , 'b6cac94c78ade6c6ffcbda629ffa520561a31788' ])
38
39
os .chdir (parent )
40
+ if not glob .glob ("binder/build/pybind11" ):
41
+ print ("pybind11 not found, cloning repo..." )
42
+ parent = os .getcwd ()
43
+ os .chdir ('binder' )
44
+ os .makedirs ('build' , exist_ok = True )
45
+ subprocess .check_call (['git' , 'clone' , 'https://github.com/RosettaCommons/pybind11.git' , 'build/pybind11' ])
46
+ os .chdir ('build/pybind11' )
47
+ # See also: pybind11 commit defined in CMakeLists.txt
48
+ subprocess .check_call (['git' , 'checkout' , '5b0a6fc2017fcc176545afe3e09c9f9885283242' ])
49
+ os .chdir (parent )
50
+
39
51
40
52
def build_binder ():
41
53
'''
@@ -46,10 +58,19 @@ def build_binder():
46
58
'''
47
59
if not glob .glob ("./build/*/*/bin/*" ):
48
60
print ("Binder not compiled, using packaged build.py..." )
49
- # Make Binder use out pybind11 version
50
- subprocess .check_call (['sed' , '-i' , "s/^_pybind11_version_ = .*/_pybind11_version_ = '5b0a6fc2017fcc176545afe3e09c9f9885283242'/g" , 'build.py' ])
51
61
# TODO: Use CPU counting that accounts for container quotas?
52
- subprocess .check_call ([sys .executable , 'build.py' , '--jobs' , str (multiprocessing .cpu_count ())])
62
+ subprocess .check_call (
63
+ [
64
+ sys .executable ,
65
+ 'build.py' ,
66
+ '--compiler' ,
67
+ 'clang' if platform .system () == 'Darwin' else 'gcc' ,
68
+ '--jobs' ,
69
+ str (multiprocessing .cpu_count ()),
70
+ '--pybind11' ,
71
+ os .path .join (os .getcwd (), 'build/pybind11' )
72
+ ]
73
+ )
53
74
return "binder/" + glob .glob ('./build/*/*/bin/' )[0 ] + "binder"
54
75
55
76
def all_sources_and_headers (include_deps = False ):
@@ -228,6 +249,16 @@ def make_bindings_code(all_includes_fn, binder_executable):
228
249
# Also make sure to look for libomp from macports or homebrew, like CMakeLists.txt does
229
250
command .append ('-I/opt/local/include/libomp' )
230
251
command .append ('-I/usr/local/include' )
252
+ else :
253
+ # With current GCC, Clang can't find the multiarch-specific *and*
254
+ # GCC-version-specific include path where the OpenMP headers live.
255
+ # So help it out.
256
+ # TODO: We're assuming we're using GCC.
257
+ compiler_version = int (subprocess .check_output (["gcc" , "-dumpversion" ]).decode ('utf-8' ).split ('.' )[0 ])
258
+ compiler_triple = subprocess .check_output (["gcc" , "-dumpmachine" ]).decode ('utf-8' ).strip ()
259
+ command .append ('-I' + f"/usr/lib/gcc/{ compiler_triple } /{ compiler_version } /include" )
260
+ # We rely on macro hacks in binder_hook_bind.hpp to translate the file
261
+ # into something Binder can understand.
231
262
232
263
# Find Jansson
233
264
jansson_flags = subprocess .check_output (['pkg-config' , '--cflags' , 'jansson' ]).decode ('utf-8' ).strip ().split (' ' )
0 commit comments