Skip to content

Commit cf75400

Browse files
committed
bindings/python/run.me: update the build procedure.
- build fat shared object on MacOS; - pull more information from sysconfig, make it work with MinGW;
1 parent d82c533 commit cf75400

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

bindings/python/run.me

+18-6
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,42 @@ def newer(*files):
1818
if not os.path.exists(rh):
1919
return True
2020
for lh in files[:-1]:
21-
if os.stat(lh).st_ctime > os.stat(rh).st_ctime:
21+
if os.stat(lh).st_mtime > os.stat(rh).st_mtime:
2222
return True
2323
return False
2424

2525

2626
if newer("../blst.h", "../libblst.a"):
2727
print("building libblst.a...") or sys.stdout.flush()
28-
subprocess.check_call(["../build.sh", "-fvisibility=hidden"] + sys.argv[1:], cwd="..")
28+
cmd = ["../build.sh", "-fvisibility=hidden"] + sys.argv[1:]
29+
if sysconfig.get_config_var('MACHDEP') == 'darwin':
30+
cmd.extend(["-arch", "arm64", "-arch", "x86_64"])
31+
try:
32+
subprocess.check_call(cmd, cwd="..")
33+
except:
34+
subprocess.check_call(["sh"] + cmd, cwd="..")
2935

3036
if newer("../blst.swg", "../blst.h", "../blst.hpp", "blst_wrap.cpp"):
3137
print("swig-ing...") or sys.stdout.flush()
3238
subprocess.check_call(["swig", "-c++", "-python", "-O",
3339
"-o", "blst_wrap.cpp", "-outdir", ".",
3440
"../blst.swg"])
3541

36-
if newer("blst_wrap.cpp", "../libblst.a", "_blst.so"):
37-
print("compiling _blst.so...") or sys.stdout.flush()
42+
blst_so = "_blst"+sysconfig.get_config_var('EXT_SUFFIX')
43+
44+
if newer("blst_wrap.cpp", "../libblst.a", blst_so):
45+
print("compiling %s..." % blst_so) or sys.stdout.flush()
3846
if sysconfig.get_config_var('MACHDEP') == 'darwin':
39-
cmd = ["c++", "-bundle", "-undefined", "dynamic_lookup"]
47+
cmd = ["c++", "-bundle", "-undefined", "dynamic_lookup",
48+
"-arch", "arm64", "-arch", "x86_64"]
4049
else:
4150
cmd = ["c++", "-shared", "-Wl,-Bsymbolic"]
42-
cmd.extend(["-o", "_blst.so", "-fPIC", "-fvisibility=hidden",
51+
cmd.extend(["-o", blst_so, "-fPIC", "-fvisibility=hidden",
4352
"-I"+sysconfig.get_config_var('INCLUDEPY'), "-I..",
4453
"-O", "-Wall", "blst_wrap.cpp", "../libblst.a"])
54+
if sysconfig.get_config_var('LIBPYTHON'):
55+
cmd.extend(["-L"+sysconfig.get_config_var('LIBDIR'),
56+
sysconfig.get_config_var('LIBPYTHON')])
4557
try:
4658
pre = subprocess.check_output(["c++", "-dM", "-E", "-x", "c++", "/dev/null"],
4759
stderr=subprocess.STDOUT)

0 commit comments

Comments
 (0)