Skip to content

Commit

Permalink
fix: python api caller
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Feb 26, 2024
1 parent 5bbae3b commit 9fbba3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions python/kcl_lib/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,13 @@ def __init__(self):
self.lib = ctypes.CDLL(os.path.join(env_path, lib_full_name()))
elif env_install_path:
install_kclvm(env_install_path)
self.lib = ctypes.CDLL(os.path.join(env_install_path, lib_full_name()))
self.lib = ctypes.CDLL(
os.path.join(env_install_path, "bin", lib_full_name())
)
else:
# 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()))
# Install temp path.
install_kclvm(self._dir.name)
self.lib = ctypes.CDLL(self._dir.name + "/bin/" + 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
Expand Down
2 changes: 1 addition & 1 deletion python/tests/parse_test.py → python/tests/exec_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_parse_api():
def test_exec_api():
import kcl_lib.api as api

# Call the `exec_program` method with appropriate arguments
Expand Down

0 comments on commit 9fbba3e

Please sign in to comment.