From c1b6eb4f7288ec2c4591eae528203654a92e6248 Mon Sep 17 00:00:00 2001 From: peefy Date: Mon, 26 Feb 2024 16:26:20 +0800 Subject: [PATCH] chore: bump kcl lib to 0.8.0-alpha.6 Signed-off-by: peefy --- python/.gitignore | 2 +- python/Makefile | 4 ++-- python/kcl_lib/api/service.py | 17 +++++++++-------- python/kcl_lib/bootstrap/__init__.py | 2 +- python/setup.py | 8 ++++---- python/tests/exec_test.py | 6 ++++++ 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/python/.gitignore b/python/.gitignore index ecf78206..787414d1 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -9,6 +9,6 @@ __pycache__ *.pyc build-result/ dist/ -kcl_lib/lib +kcl_lib/bin kcl_lib.egg-info/ .eggs/ diff --git a/python/Makefile b/python/Makefile index c6e2c81a..731b5d14 100644 --- a/python/Makefile +++ b/python/Makefile @@ -4,9 +4,9 @@ dist: rm -rf build rm -rf dist rm -rf kcl_lib.egg-info - rm -rf kcl_lib/lib/** + rm -rf kcl_lib/bin/** for platform in $(PLATFORMS); do \ - rm -rf build && rm -rf kcl_lib/lib && python3 setup.py bdist_wheel --plat-name $$platform; \ + rm -rf build && rm -rf kcl_lib/bin && python3 setup.py bdist_wheel --plat-name $$platform; \ done python3 -m twine upload dist/kcl_lib-* diff --git a/python/kcl_lib/api/service.py b/python/kcl_lib/api/service.py index 38b00309..7c360ba6 100644 --- a/python/kcl_lib/api/service.py +++ b/python/kcl_lib/api/service.py @@ -5,7 +5,7 @@ from kcl_lib.bootstrap import ( KCLVM_CLI_INSTALL_PATH_ENV_VAR, KCLVM_CLI_BIN_PATH_ENV_VAR, - KCLVM_CLI_USE_RELEASE_ENV_VAR, + KCLVM_CLI_USE_TEST_ENV_VAR, lib_full_name, install_kclvm, ) @@ -104,7 +104,7 @@ def __init__(self): self._dir = tempfile.TemporaryDirectory() env_path = os.environ.get(KCLVM_CLI_BIN_PATH_ENV_VAR) env_install_path = os.environ.get(KCLVM_CLI_INSTALL_PATH_ENV_VAR) - env_use_release = os.environ.get(KCLVM_CLI_USE_RELEASE_ENV_VAR) + env_use_test = os.environ.get(KCLVM_CLI_USE_TEST_ENV_VAR) if env_path: self.lib = ctypes.CDLL(os.path.join(env_path, lib_full_name())) elif env_install_path: @@ -112,15 +112,16 @@ def __init__(self): self.lib = ctypes.CDLL( os.path.join(env_install_path, "bin", lib_full_name()) ) - elif env_use_release: - # The release lib is located at "kcl_lib/lib/" - lib_path = LIB_ROOT.joinpath("lib") - os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = str(lib_path) - self.lib = ctypes.CDLL(str(lib_path.joinpath(lib_full_name()))) - else: + # Default test cases + elif env_use_test: # Install temp path. install_kclvm(self._dir.name) self.lib = ctypes.CDLL(self._dir.name + "/bin/" + lib_full_name()) + else: + # The release lib is located at "kcl_lib/bin/" + lib_path = LIB_ROOT.joinpath("bin") + os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = str(lib_path) + self.lib = ctypes.CDLL(str(lib_path.joinpath(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 diff --git a/python/kcl_lib/bootstrap/__init__.py b/python/kcl_lib/bootstrap/__init__.py index 9c669301..1eee179d 100644 --- a/python/kcl_lib/bootstrap/__init__.py +++ b/python/kcl_lib/bootstrap/__init__.py @@ -6,7 +6,7 @@ KCLVM_VERSION = "0.8.0-alpha.5" # You should replace this with actual version KCLVM_CLI_BIN_PATH_ENV_VAR = "KCLVM_CLI_BIN_PATH" KCLVM_CLI_INSTALL_PATH_ENV_VAR = "KCLVM_CLI_INSTALL_PATH" -KCLVM_CLI_USE_RELEASE_ENV_VAR = "KCLVM_CLI_USE_RELEASE" +KCLVM_CLI_USE_TEST_ENV_VAR = "KCLVM_CLI_USE_TEST" LIB_NAME = "kclvm_cli_cdylib" diff --git a/python/setup.py b/python/setup.py index 8038c83f..eed8d7e5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -107,13 +107,13 @@ def copyfile(src: pathlib.Path, dst: pathlib.Path) -> str: return str(dst.relative_to(pathlib.Path(__file__).parent)) -# Copy libs to the kcl_lib/lib folder +# Copy libs to the kcl_lib/bin folder def copy_libs(): source_dir = pathlib.Path(__file__).parent.parent - target_dir = pathlib.Path(__file__).parent.joinpath("kcl_lib").joinpath("lib") + target_dir = pathlib.Path(__file__).parent.joinpath("kcl_lib").joinpath("bin") data_files = [] data_files.append(copyfile(source_dir / cli_lib(), target_dir / lib_name())) - if PLATFORM in ["windows"]: + if PLATFORM in ["win32", "windows"]: data_files.append( copyfile(source_dir / export_lib(), target_dir / export_lib_name()) ) @@ -134,7 +134,7 @@ def copy_libs(): setup( name="kcl_lib", author="KCL Authors", - version="0.8.0-alpha.5", + version="0.8.0-alpha.6", license="Apache License 2.0", python_requires=">=3.7", description="KCL Artifact Library for Python", diff --git a/python/tests/exec_test.py b/python/tests/exec_test.py index d7b8d201..1e45aedd 100644 --- a/python/tests/exec_test.py +++ b/python/tests/exec_test.py @@ -1,3 +1,9 @@ +import os +import kcl_lib.bootstrap as bootstrap + +os.environ[bootstrap.KCLVM_CLI_USE_TEST_ENV_VAR] = "ok" + + def test_exec_api(): import kcl_lib.api as api