@@ -26,31 +26,36 @@ def get_boost_libraries():
2626 # if find_library(lib):
2727 # return [lib]
2828 # raise RuntimeError("Cannot find a suitable Boost.Python library.")
29- """
30- Prefer the boost_python library shipped in the active conda env.
31- Falls back to un-tagged 'boost_python' only if nothing else is found .
29+ """
30+ Link against both Boost.Python and Boost.Serialization
31+ from the active conda env’s lib/ directory .
3232 """
3333 conda_prefix = os .environ .get ("CONDA_PREFIX" )
3434 if not conda_prefix :
3535 raise EnvironmentError ("CONDA_PREFIX is not set; please activate your conda environment." )
3636
3737 libdir = Path (conda_prefix ) / "lib"
38- # e.g. look for libboost_python312.so, libboost_python3.so, libboost_python.so
39- major , minor = sys .version_info [0 ], sys .version_info [1 ]
40- candidates = [
41- f"boost_python{ major } { minor } " ,
42- f"boost_python{ major } " ,
43- "boost_python" ,
44- ]
45- for name in candidates :
46- so = libdir / f"lib{ name } .so"
47- if so .exists ():
48- return [name ]
49-
50- raise RuntimeError (
51- f"Could not find any of { candidates !r} in { libdir } ; "
52- "please install Boost into your conda env."
53- )
38+ major , minor = sys .version_info [:2 ]
39+
40+ # look for the _python_ library
41+ py_cands = [f"boost_python{ major } { minor } " , f"boost_python{ major } " , "boost_python" ]
42+ for lib in py_cands :
43+ if (libdir / f"lib{ lib } .so" ).exists ():
44+ boost_py = lib
45+ break
46+ else :
47+ raise RuntimeError (f"Could not find any of { py_cands !r} in { libdir } " )
48+
49+ # look for the _serialization_ library
50+ ser_cands = ["boost_serialization" ]
51+ for lib in ser_cands :
52+ if (libdir / f"lib{ lib } .so" ).exists ():
53+ boost_ser = lib
54+ break
55+ else :
56+ raise RuntimeError (f"Could not find any of { ser_cands !r} in { libdir } " )
57+
58+ return [boost_ser , boost_py ]
5459
5560
5661def get_boost_config ():
0 commit comments