Show libxgboost.so path in build info. (#7893)

This commit is contained in:
Jiaming Yuan 2022-05-13 18:08:56 +08:00 committed by GitHub
parent 9fa7ed1743
commit c8f9d4b6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,6 +156,7 @@ def _load_lib() -> ctypes.CDLL:
os.environ['PATH'] = os.pathsep.join( os.environ['PATH'] = os.pathsep.join(
pathBackup + [os.path.dirname(lib_path)]) pathBackup + [os.path.dirname(lib_path)])
lib = ctypes.cdll.LoadLibrary(lib_path) lib = ctypes.cdll.LoadLibrary(lib_path)
setattr(lib, "path", os.path.normpath(lib_path))
lib_success = True lib_success = True
except OSError as e: except OSError as e:
os_error_list.append(str(e)) os_error_list.append(str(e))
@ -233,6 +234,7 @@ def build_info() -> dict:
_check_call(_LIB.XGBuildInfo(ctypes.byref(j_info))) _check_call(_LIB.XGBuildInfo(ctypes.byref(j_info)))
assert j_info.value is not None assert j_info.value is not None
res = json.loads(j_info.value.decode()) # pylint: disable=no-member res = json.loads(j_info.value.decode()) # pylint: disable=no-member
res["libxgboost"] = _LIB.path
return res return res