7
7
"""
8
8
9
9
import glob
10
+ import os
10
11
import sys
11
12
from ctypes .util import find_library
13
+ from pathlib import Path
12
14
13
15
import numpy
14
16
from setuptools import Extension , setup
@@ -26,11 +28,33 @@ def get_boost_libraries():
26
28
raise RuntimeError ("Cannot find a suitable Boost.Python library." )
27
29
28
30
31
+ def get_boost_config ():
32
+ boost_path = os .environ .get ("BOOST_PATH" , "" )
33
+ if boost_path :
34
+ inc = Path (boost_path ) / "include"
35
+ lib = Path (boost_path ) / "lib"
36
+ else :
37
+ conda_prefix = os .environ .get ("CONDA_PREFIX" )
38
+ if not conda_prefix :
39
+ raise EnvironmentError (
40
+ "Neither BOOST_PATH nor CONDA_PREFIX are set. " "Please install Boost or set BOOST_PATH."
41
+ )
42
+ if os .name == "nt" :
43
+ inc = Path (conda_prefix ) / "Library" / "include"
44
+ lib = Path (conda_prefix ) / "Library" / "lib"
45
+ else :
46
+ inc = Path (conda_prefix ) / "include"
47
+ lib = Path (conda_prefix ) / "lib"
48
+ return {"include_dirs" : [str (inc )], "library_dirs" : [str (lib )]}
49
+
50
+
51
+ boost_cfg = get_boost_config ()
29
52
ext_kws = {
30
53
"libraries" : ["diffpy" ] + get_boost_libraries (),
31
54
"extra_compile_args" : ["-std=c++11" ],
32
55
"extra_link_args" : [],
33
- "include_dirs" : [numpy .get_include ()],
56
+ "include_dirs" : [numpy .get_include ()] + boost_cfg ["include_dirs" ],
57
+ "library_dirs" : boost_cfg ["library_dirs" ],
34
58
}
35
59
36
60
0 commit comments