File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010import glob
1111import os
12+ import sys
13+ from ctypes .util import find_library
1214from pathlib import Path
1315
1416import numpy as np
1719# Helper functions -----------------------------------------------------------
1820
1921
20- def check_boost_libraries (lib_dir ):
21- pattern = "libboost_python*.*" if os .name != "nt" else "boost_python*.lib"
22- found = list (lib_dir .glob (pattern ))
23- if not found :
24- raise EnvironmentError (
25- f"No boost_python libraries found in conda environment"
26- f" at { lib_dir } . Please install libboost_python in your "
27- f"conda environment."
28- )
29-
30- # convert into linker names
31- lib = []
32- for libpath in found :
33- name = libpath .stem
34- if name .startswith ("lib" ):
35- name = name [3 :]
36- lib .append (name )
37- return lib
22+ def get_boost_libraries ():
23+ base_lib = "boost_python"
24+ major , minor = str (sys .version_info [0 ]), str (sys .version_info [1 ])
25+ tags = [f"{ major } { minor } " , major , "" ]
26+ mttags = ["" , "-mt" ]
27+ candidates = [base_lib + tag for tag in tags for mt in mttags ] + [base_lib ]
28+ for lib in candidates :
29+ if find_library (lib ):
30+ return [lib ]
31+ raise RuntimeError ("Cannot find a suitable Boost.Python library." )
3832
3933
4034def get_env_config ():
@@ -63,7 +57,7 @@ def create_extensions():
6357 else :
6458 objcryst_lib = "ObjCryst"
6559
66- libraries = [objcryst_lib ] + check_boost_libraries ( Path ( library_dirs [ 0 ]) )
60+ libraries = [objcryst_lib ] + get_boost_libraries ( )
6761 extra_objects = []
6862 extra_compile_args = []
6963 extra_link_args = []
You can’t perform that action at this time.
0 commit comments