|
17 | 17 |
|
18 | 18 |
|
19 | 19 | 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.") |
50 | 29 |
|
51 | 30 |
|
52 | 31 | def get_boost_config():
|
@@ -83,7 +62,7 @@ def get_objcryst_libraries():
|
83 | 62 | libs = []
|
84 | 63 | for fn in os.listdir(libdir):
|
85 | 64 | low = fn.lower()
|
86 |
| - if low.endswith(".lib") and "objcryst" in low: |
| 65 | + if "objcryst" in low: |
87 | 66 | libs.append(os.path.splitext(fn)[0])
|
88 | 67 | if not libs:
|
89 | 68 | raise RuntimeError(f"No ObjCryst libraries found in {libdir}")
|
|
0 commit comments