Fix libpath logic for Windows (#9712)
* Fix libpath logic for Windows (#9687) * Use sys.base_prefix instead of sys.prefix (#9711) * Use sys.base_prefix instead of sys.prefix * Update libpath.py too
This commit is contained in:
parent
7a02facc9d
commit
01d59ded00
@ -132,16 +132,28 @@ def locate_or_build_libxgboost(
|
||||
|
||||
if build_config.use_system_libxgboost:
|
||||
# Find libxgboost from system prefix
|
||||
sys_base_prefix = pathlib.Path(sys.base_prefix).absolute().resolve()
|
||||
libxgboost_sys = sys_base_prefix / "lib" / _lib_name()
|
||||
if not libxgboost_sys.exists():
|
||||
raise RuntimeError(
|
||||
f"use_system_libxgboost was specified but {_lib_name()} is "
|
||||
f"not found in {libxgboost_sys.parent}"
|
||||
)
|
||||
|
||||
logger.info("Using system XGBoost: %s", str(libxgboost_sys))
|
||||
return libxgboost_sys
|
||||
sys_prefix = pathlib.Path(sys.base_prefix)
|
||||
sys_prefix_candidates = [
|
||||
sys_prefix / "lib",
|
||||
# Paths possibly used on Windows
|
||||
sys_prefix / "bin",
|
||||
sys_prefix / "Library",
|
||||
sys_prefix / "Library" / "bin",
|
||||
sys_prefix / "Library" / "lib",
|
||||
]
|
||||
sys_prefix_candidates = [
|
||||
p.expanduser().resolve() for p in sys_prefix_candidates
|
||||
]
|
||||
for candidate_dir in sys_prefix_candidates:
|
||||
libtreelite_sys = candidate_dir / _lib_name()
|
||||
if libtreelite_sys.exists():
|
||||
logger.info("Using system XGBoost: %s", str(libtreelite_sys))
|
||||
return libtreelite_sys
|
||||
raise RuntimeError(
|
||||
f"use_system_libxgboost was specified but {_lib_name()} is "
|
||||
f"not found. Paths searched (in order): \n"
|
||||
+ "\n".join([f"* {str(p)}" for p in sys_prefix_candidates])
|
||||
)
|
||||
|
||||
libxgboost = locate_local_libxgboost(toplevel_dir, logger=logger)
|
||||
if libxgboost is not None:
|
||||
|
||||
@ -31,16 +31,15 @@ def find_lib_path() -> List[str]:
|
||||
]
|
||||
|
||||
if sys.platform == "win32":
|
||||
if platform.architecture()[0] == "64bit":
|
||||
dll_path.append(os.path.join(curr_path, "../../windows/x64/Release/"))
|
||||
# hack for pip installation when copy all parent source
|
||||
# directory here
|
||||
dll_path.append(os.path.join(curr_path, "./windows/x64/Release/"))
|
||||
else:
|
||||
dll_path.append(os.path.join(curr_path, "../../windows/Release/"))
|
||||
# hack for pip installation when copy all parent source
|
||||
# directory here
|
||||
dll_path.append(os.path.join(curr_path, "./windows/Release/"))
|
||||
# On Windows, Conda may install libs in different paths
|
||||
dll_path.extend(
|
||||
[
|
||||
os.path.join(sys.base_prefix, "bin"),
|
||||
os.path.join(sys.base_prefix, "Library"),
|
||||
os.path.join(sys.base_prefix, "Library", "bin"),
|
||||
os.path.join(sys.base_prefix, "Library", "lib"),
|
||||
]
|
||||
)
|
||||
dll_path = [os.path.join(p, "xgboost.dll") for p in dll_path]
|
||||
elif sys.platform.startswith(("linux", "freebsd", "emscripten")):
|
||||
dll_path = [os.path.join(p, "libxgboost.so") for p in dll_path]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user