Skip to content

Commit e7c6457

Browse files
authored
Merge pull request #44 from kcl-lang/fix-kcl-py-release
chore: bump kcl lib to 0.8.0-alpha.6
2 parents ec71c93 + c1b6eb4 commit e7c6457

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

python/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ __pycache__
99
*.pyc
1010
build-result/
1111
dist/
12-
kcl_lib/lib
12+
kcl_lib/bin
1313
kcl_lib.egg-info/
1414
.eggs/

python/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ dist:
44
rm -rf build
55
rm -rf dist
66
rm -rf kcl_lib.egg-info
7-
rm -rf kcl_lib/lib/**
7+
rm -rf kcl_lib/bin/**
88
for platform in $(PLATFORMS); do \
9-
rm -rf build && rm -rf kcl_lib/lib && python3 setup.py bdist_wheel --plat-name $$platform; \
9+
rm -rf build && rm -rf kcl_lib/bin && python3 setup.py bdist_wheel --plat-name $$platform; \
1010
done
1111
python3 -m twine upload dist/kcl_lib-*
1212

python/kcl_lib/api/service.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from kcl_lib.bootstrap import (
66
KCLVM_CLI_INSTALL_PATH_ENV_VAR,
77
KCLVM_CLI_BIN_PATH_ENV_VAR,
8-
KCLVM_CLI_USE_RELEASE_ENV_VAR,
8+
KCLVM_CLI_USE_TEST_ENV_VAR,
99
lib_full_name,
1010
install_kclvm,
1111
)
@@ -104,23 +104,24 @@ def __init__(self):
104104
self._dir = tempfile.TemporaryDirectory()
105105
env_path = os.environ.get(KCLVM_CLI_BIN_PATH_ENV_VAR)
106106
env_install_path = os.environ.get(KCLVM_CLI_INSTALL_PATH_ENV_VAR)
107-
env_use_release = os.environ.get(KCLVM_CLI_USE_RELEASE_ENV_VAR)
107+
env_use_test = os.environ.get(KCLVM_CLI_USE_TEST_ENV_VAR)
108108
if env_path:
109109
self.lib = ctypes.CDLL(os.path.join(env_path, lib_full_name()))
110110
elif env_install_path:
111111
install_kclvm(env_install_path)
112112
self.lib = ctypes.CDLL(
113113
os.path.join(env_install_path, "bin", lib_full_name())
114114
)
115-
elif env_use_release:
116-
# The release lib is located at "kcl_lib/lib/"
117-
lib_path = LIB_ROOT.joinpath("lib")
118-
os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = str(lib_path)
119-
self.lib = ctypes.CDLL(str(lib_path.joinpath(lib_full_name())))
120-
else:
115+
# Default test cases
116+
elif env_use_test:
121117
# Install temp path.
122118
install_kclvm(self._dir.name)
123119
self.lib = ctypes.CDLL(self._dir.name + "/bin/" + lib_full_name())
120+
else:
121+
# The release lib is located at "kcl_lib/bin/"
122+
lib_path = LIB_ROOT.joinpath("bin")
123+
os.environ[KCLVM_CLI_BIN_PATH_ENV_VAR] = str(lib_path)
124+
self.lib = ctypes.CDLL(str(lib_path.joinpath(lib_full_name())))
124125
# Assuming the shared library exposes a function `kclvm_service_new`
125126
self.lib.kclvm_service_new.argtypes = [ctypes.c_uint64]
126127
self.lib.kclvm_service_new.restype = ctypes.c_void_p

python/kcl_lib/bootstrap/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
KCLVM_VERSION = "0.8.0-alpha.5" # You should replace this with actual version
77
KCLVM_CLI_BIN_PATH_ENV_VAR = "KCLVM_CLI_BIN_PATH"
88
KCLVM_CLI_INSTALL_PATH_ENV_VAR = "KCLVM_CLI_INSTALL_PATH"
9-
KCLVM_CLI_USE_RELEASE_ENV_VAR = "KCLVM_CLI_USE_RELEASE"
9+
KCLVM_CLI_USE_TEST_ENV_VAR = "KCLVM_CLI_USE_TEST"
1010
LIB_NAME = "kclvm_cli_cdylib"
1111

1212

python/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def copyfile(src: pathlib.Path, dst: pathlib.Path) -> str:
107107
return str(dst.relative_to(pathlib.Path(__file__).parent))
108108

109109

110-
# Copy libs to the kcl_lib/lib folder
110+
# Copy libs to the kcl_lib/bin folder
111111
def copy_libs():
112112
source_dir = pathlib.Path(__file__).parent.parent
113-
target_dir = pathlib.Path(__file__).parent.joinpath("kcl_lib").joinpath("lib")
113+
target_dir = pathlib.Path(__file__).parent.joinpath("kcl_lib").joinpath("bin")
114114
data_files = []
115115
data_files.append(copyfile(source_dir / cli_lib(), target_dir / lib_name()))
116-
if PLATFORM in ["windows"]:
116+
if PLATFORM in ["win32", "windows"]:
117117
data_files.append(
118118
copyfile(source_dir / export_lib(), target_dir / export_lib_name())
119119
)
@@ -134,7 +134,7 @@ def copy_libs():
134134
setup(
135135
name="kcl_lib",
136136
author="KCL Authors",
137-
version="0.8.0-alpha.5",
137+
version="0.8.0-alpha.6",
138138
license="Apache License 2.0",
139139
python_requires=">=3.7",
140140
description="KCL Artifact Library for Python",

python/tests/exec_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import os
2+
import kcl_lib.bootstrap as bootstrap
3+
4+
os.environ[bootstrap.KCLVM_CLI_USE_TEST_ENV_VAR] = "ok"
5+
6+
17
def test_exec_api():
28
import kcl_lib.api as api
39

0 commit comments

Comments
 (0)