Skip to content

Commit 93c7302

Browse files
committed
fix for mac
1 parent 25cc682 commit 93c7302

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

setup.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,15 @@
1717

1818

1919
def get_boost_libraries():
20-
"""
21-
Link against both Boost.Python and Boost.Serialization
22-
from the active conda env’s lib/ directory.
23-
"""
24-
conda_prefix = os.environ.get("CONDA_PREFIX")
25-
if not conda_prefix:
26-
raise EnvironmentError("CONDA_PREFIX is not set; please activate your conda environment.")
27-
28-
libdir = Path(conda_prefix) / "lib"
29-
major, minor = sys.version_info[:2]
30-
31-
# look for the _python_ library
32-
py_cands = [f"boost_python{major}{minor}", f"boost_python{major}", "boost_python"]
33-
for lib in py_cands:
34-
if (libdir / f"lib{lib}.so").exists():
35-
boost_py = lib
36-
break
37-
else:
38-
raise RuntimeError(f"Could not find any of {py_cands!r} in {libdir}")
39-
40-
# look for the _serialization_ library
41-
ser_cands = ["boost_serialization"]
42-
for lib in ser_cands:
43-
if (libdir / f"lib{lib}.so").exists():
44-
boost_ser = lib
45-
break
46-
else:
47-
raise RuntimeError(f"Could not find any of {ser_cands!r} in {libdir}")
48-
49-
return [boost_ser, boost_py]
20+
base_lib = "boost_python"
21+
major, minor = str(sys.version_info[0]), str(sys.version_info[1])
22+
tags = [f"{major}{minor}", major, ""]
23+
mttags = ["", "-mt"]
24+
candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib]
25+
for lib in candidates:
26+
if find_library(lib):
27+
return [lib]
28+
raise RuntimeError("Cannot find a suitable Boost.Python library.")
5029

5130

5231
def get_boost_config():
@@ -83,7 +62,7 @@ def get_objcryst_libraries():
8362
libs = []
8463
for fn in os.listdir(libdir):
8564
low = fn.lower()
86-
if low.endswith(".lib") and "objcryst" in low:
65+
if "objcryst" in low:
8766
libs.append(os.path.splitext(fn)[0])
8867
if not libs:
8968
raise RuntimeError(f"No ObjCryst libraries found in {libdir}")

0 commit comments

Comments
 (0)