From 0bbe529093b335dd6a0f23abd3962f13f0c8b339 Mon Sep 17 00:00:00 2001 From: peefy Date: Mon, 26 Feb 2024 13:19:15 +0800 Subject: [PATCH] fix: kcl lib install Signed-off-by: peefy --- python/kcl_lib/api/service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/kcl_lib/api/service.py b/python/kcl_lib/api/service.py index 38c8930f..8104f217 100644 --- a/python/kcl_lib/api/service.py +++ b/python/kcl_lib/api/service.py @@ -109,7 +109,14 @@ def __init__(self): install_kclvm(env_install_path) self.lib = ctypes.CDLL(os.path.join(env_install_path, lib_full_name())) else: - self.lib = ctypes.CDLL(os.path.join(lib_path(), lib_full_name())) + # Set the kcl lib and open it. + path = lib_path() + path_env = os.environ.get("PATH", "") + bin_path_str = str(path) + new_path_env = f"{path_env}{os.pathsep}{bin_path_str}" + os.environ["PATH"] = new_path_env + os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = bin_path_str + self.lib = ctypes.CDLL(os.path.join(path, lib_full_name())) # Assuming the shared library exposes a function `kclvm_service_new` self.lib.kclvm_service_new.argtypes = [ctypes.c_uint64] self.lib.kclvm_service_new.restype = ctypes.c_void_p