Skip to content

Commit

Permalink
chore: bump kcl lib to 0.8.0-alpha.6
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 ec71c93 commit c1b6eb4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ __pycache__
*.pyc
build-result/
dist/
kcl_lib/lib
kcl_lib/bin
kcl_lib.egg-info/
.eggs/
4 changes: 2 additions & 2 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-*

Expand Down
17 changes: 9 additions & 8 deletions python/kcl_lib/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -104,23 +104,24 @@ 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:
install_kclvm(env_install_path)
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
Expand Down
2 changes: 1 addition & 1 deletion python/kcl_lib/bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
8 changes: 4 additions & 4 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
)
Expand All @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions python/tests/exec_test.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit c1b6eb4

Please sign in to comment.