77"""
88
99import glob
10+ import os
1011import sys
1112from ctypes .util import find_library
13+ from pathlib import Path
1214
1315import numpy
1416from setuptools import Extension , setup
@@ -26,11 +28,33 @@ def get_boost_libraries():
2628 raise RuntimeError ("Cannot find a suitable Boost.Python library." )
2729
2830
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 ()
2952ext_kws = {
3053 "libraries" : ["diffpy" ] + get_boost_libraries (),
3154 "extra_compile_args" : ["-std=c++11" ],
3255 "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" ],
3458}
3559
3660
0 commit comments