File tree Expand file tree Collapse file tree 1 file changed +13
-19
lines changed Expand file tree Collapse file tree 1 file changed +13
-19
lines changed Original file line number Diff line number Diff line change 9
9
10
10
import glob
11
11
import os
12
+ import sys
13
+ from ctypes .util import find_library
12
14
from pathlib import Path
13
15
14
16
import numpy as np
17
19
# Helper functions -----------------------------------------------------------
18
20
19
21
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." )
38
32
39
33
40
34
def get_env_config ():
@@ -63,7 +57,7 @@ def create_extensions():
63
57
else :
64
58
objcryst_lib = "ObjCryst"
65
59
66
- libraries = [objcryst_lib ] + check_boost_libraries ( Path ( library_dirs [ 0 ]) )
60
+ libraries = [objcryst_lib ] + get_boost_libraries ( )
67
61
extra_objects = []
68
62
extra_compile_args = []
69
63
extra_link_args = []
You can’t perform that action at this time.
0 commit comments