Skip to content

Commit 790a631

Browse files
committed
update subprocess: use list pass commands to avoid errors; update windows type check: use Union from typing
1 parent a8403d7 commit 790a631

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

clone_and_build.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import shutil
55
import time
6+
from typing import Union
67
from git import repo
78
from git import TagReference
89
from packaging import version
@@ -41,7 +42,7 @@ def tags_filter(tags: list) -> list:
4142
ret_tags.append(main)
4243
return ret_tags
4344

44-
def build_repo(pkpy_repo:repo.Repo, tag: TagReference | BranchAsTag) -> float:
45+
def build_repo(pkpy_repo:repo.Repo, tag: Union[TagReference, BranchAsTag]) -> float:
4546
"""Build the repo with specific tag/branch static, copy excutable into
4647
the corresponding folder
4748
"""
@@ -58,14 +59,33 @@ def build_repo(pkpy_repo:repo.Repo, tag: TagReference | BranchAsTag) -> float:
5859
os.mkdir(f"All_in_one/pkpy-{tag.name.lstrip('v')}")
5960
# build the current version of pkpy
6061
try:
61-
subprocess.run('python prebuild.py', cwd='pocketpy', stderr=subprocess.PIPE)
62+
subprocess.run([sys.executable, 'prebuild.py'], cwd='pocketpy', stderr=subprocess.PIPE)
6263
except subprocess.CalledProcessError as e:
6364
print(f'prebuild.py run failed with return code {e.returncode}: {e.stderr}')
64-
65+
cmake_cmd = [
66+
"cmake",
67+
"-B", "build",
68+
"-S", ".",
69+
"-DPK_ENABLE_OS=ON",
70+
"-DPK_ENABLE_THREADS=OFF",
71+
"-DPK_ENABLE_DETERMINISM=OFF",
72+
"-DPK_ENABLE_WATCHDOG=OFF",
73+
"-DPK_ENABLE_CUSTOM_SNAME=OFF",
74+
"-DPK_ENABLE_MIMALLOC=OFF",
75+
"-DPK_BUILD_MODULE_LZ4=OFF",
76+
"-DPK_BUILD_MODULE_LIBHV=OFF",
77+
"-DCMAKE_BUILD_TYPE=Release"
78+
]
79+
80+
build_cmd = [
81+
"cmake",
82+
"--build", "build",
83+
"--config", "Release"
84+
]
6585
start_time = time.perf_counter()
66-
subprocess.run('cmake -B build -S . -DPK_ENABLE_OS=ON -DPK_ENABLE_THREADS=OFF -DPK_ENABLE_DETERMINISM=OFF -DPK_ENABLE_WATCHDOG=OFF -DPK_ENABLE_CUSTOM_SNAME=OFF -DPK_ENABLE_MIMALLOC=OFF -DPK_BUILD_MODULE_LZ4=OFF -DPK_BUILD_MODULE_LIBHV=OFF -DCMAKE_BUILD_TYPE=Release',
86+
subprocess.run(cmake_cmd,
6787
cwd='pocketpy', check=True)
68-
subprocess.run(f'cmake --build build --config Release', cwd = 'pocketpy', check=True)
88+
subprocess.run(build_cmd, cwd = 'pocketpy', check=True)
6989
elapsed_time = time.perf_counter() - start_time
7090

7191
if sys.platform == 'win32':

0 commit comments

Comments
 (0)