@@ -48,20 +48,51 @@ def get_boost_config():
4848 return {"include_dirs" : [str (inc )], "library_dirs" : [str (lib )]}
4949
5050
51+ def get_objcryst_libraries ():
52+ conda_prefix = os .environ .get ("CONDA_PREFIX" )
53+ if not conda_prefix :
54+ raise EnvironmentError (
55+ "CONDA_PREFIX is not set. Please install ObjCryst using conda and activate the environment."
56+ )
57+ if os .name == "nt" :
58+ libdir = Path (conda_prefix ) / "Library" / "lib"
59+ else :
60+ libdir = Path (conda_prefix ) / "lib"
61+
62+ libs = []
63+ for fn in os .listdir (libdir ):
64+ stem = Path (fn ).stem
65+ if "objcryst" not in stem .lower ():
66+ continue
67+ # strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst
68+ if os .name != "nt" and stem .startswith ("lib" ):
69+ stem = stem [3 :]
70+ libs .append (stem )
71+
72+ if not libs :
73+ raise RuntimeError (f"No ObjCryst libraries found in { libdir } " )
74+ return libs
75+
76+
5177if os .name == "nt" :
5278 compile_args = ["/std:c++14" ]
5379 macros = [("_USE_MATH_DEFINES" , None )]
80+ extra_link_args = ["/FORCE:MULTIPLE" ]
5481else :
5582 compile_args = ["-std=c++11" ]
5683 macros = []
84+ extra_link_args = []
5785
5886boost_cfg = get_boost_config ()
87+ objcryst_libs = get_objcryst_libraries ()
88+
5989ext_kws = {
60- "libraries" : ["diffpy" ] + get_boost_libraries (),
90+ "libraries" : ["diffpy" ] + get_boost_libraries () + objcryst_libs ,
6191 "extra_compile_args" : compile_args ,
62- "extra_link_args" : [] ,
92+ "extra_link_args" : extra_link_args ,
6393 "include_dirs" : [numpy .get_include ()] + boost_cfg ["include_dirs" ],
6494 "library_dirs" : boost_cfg ["library_dirs" ],
95+ # "runtime_library_dirs": boost_cfg["library_dirs"],
6596 "define_macros" : macros ,
6697}
6798
0 commit comments