Skip to content

Commit

Permalink
Use sys.base_prefix instead of sys.prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverholworthy committed Jun 30, 2023
1 parent 01fd99d commit 3e7f7a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ There are several ways to build and install the package from source:
import sys
import pathlib
libpath = pathlib.Path(sys.prefix).joinpath("lib", "libxgboost.so")
libpath = pathlib.Path(sys.base_prefix).joinpath("lib", "libxgboost.so")
assert libpath.exists()
Then pass ``use_system_libxgboost=True`` option to ``pip install``:
Expand Down
4 changes: 2 additions & 2 deletions python-package/packager/nativelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def locate_or_build_libxgboost(

if build_config.use_system_libxgboost:
# Find libxgboost from system prefix
sys_prefix = pathlib.Path(sys.prefix).absolute().resolve()
libxgboost_sys = sys_prefix / "lib" / _lib_name()
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 "
Expand Down
6 changes: 3 additions & 3 deletions python-package/xgboost/libpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def find_lib_path() -> List[str]:
os.path.join(curr_path, os.path.pardir, os.path.pardir, "lib"),
# use libxgboost from a system prefix, if available. This should be the last
# option.
os.path.join(sys.base_prefix, 'lib'),
os.path.join(sys.base_prefix, "lib"),
]

if sys.platform == "win32":
Expand Down Expand Up @@ -62,8 +62,8 @@ def find_lib_path() -> List[str]:
+ ("\n- ".join(dll_path))
+ "\nXGBoost Python package path: "
+ curr_path
+ "\nsys.prefix: "
+ sys.prefix
+ "\nsys.base_prefix: "
+ sys.base_prefix
+ "\nSee: "
+ link
+ " for installing XGBoost."
Expand Down

0 comments on commit 3e7f7a0

Please sign in to comment.