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:
committed by
GitHub
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:
|
||||
|
||||
Reference in New Issue
Block a user