Skip to content

Commit 9fbba3e

Browse files
committed
fix: python api caller
Signed-off-by: peefy <xpf6677@163.com>
1 parent 5bbae3b commit 9fbba3e

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

python/kcl_lib/api/service.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,13 @@ def __init__(self):
107107
self.lib = ctypes.CDLL(os.path.join(env_path, lib_full_name()))
108108
elif env_install_path:
109109
install_kclvm(env_install_path)
110-
self.lib = ctypes.CDLL(os.path.join(env_install_path, lib_full_name()))
110+
self.lib = ctypes.CDLL(
111+
os.path.join(env_install_path, "bin", lib_full_name())
112+
)
111113
else:
112-
# Set the kcl lib and open it.
113-
path = lib_path()
114-
path_env = os.environ.get("PATH", "")
115-
bin_path_str = str(path)
116-
new_path_env = f"{path_env}{os.pathsep}{bin_path_str}"
117-
os.environ["PATH"] = new_path_env
118-
os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = bin_path_str
119-
self.lib = ctypes.CDLL(os.path.join(path, lib_full_name()))
114+
# Install temp path.
115+
install_kclvm(self._dir.name)
116+
self.lib = ctypes.CDLL(self._dir.name + "/bin/" + lib_full_name())
120117
# Assuming the shared library exposes a function `kclvm_service_new`
121118
self.lib.kclvm_service_new.argtypes = [ctypes.c_uint64]
122119
self.lib.kclvm_service_new.restype = ctypes.c_void_p

python/tests/parse_test.py renamed to python/tests/exec_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def test_parse_api():
1+
def test_exec_api():
22
import kcl_lib.api as api
33

44
# Call the `exec_program` method with appropriate arguments

0 commit comments

Comments
 (0)