diff --git a/amalgamate.py b/amalgamate.py index 1688d558..0d7a7d18 100644 --- a/amalgamate.py +++ b/amalgamate.py @@ -5,7 +5,7 @@ import sys import time from typing import List, Dict -assert os.system("python prebuild.py") == 0 +assert os.system(f"{sys.executable} prebuild.py") == 0 ROOT = 'include/pocketpy' PUBLIC_HEADERS = ['config.h', 'export.h', 'vmath.h', 'pocketpy.h'] diff --git a/build.sh b/build.sh index 7dbbfc54..dffad1c6 100644 --- a/build.sh +++ b/build.sh @@ -8,7 +8,7 @@ if ! type -P clang >/dev/null 2>&1; then fi echo "> Running prebuild.py... " -python prebuild.py +command -v python3 >/dev/null 2>&1 && python3 prebuild.py || python prebuild.py if [ $? -ne 0 ]; then echo "prebuild.py failed." diff --git a/build_darwin_libs.sh b/build_darwin_libs.sh index fa73556c..3997a41d 100644 --- a/build_darwin_libs.sh +++ b/build_darwin_libs.sh @@ -1,6 +1,9 @@ set -e -python amalgamate.py +# Use python3 if available, otherwise fall back to python +PYTHON=$(command -v python3 >/dev/null 2>&1 && echo python3 || echo python) + +$PYTHON amalgamate.py rm -rf build mkdir build @@ -20,4 +23,4 @@ cmake --build . --config Release cd ../ -python scripts/merge_built_libraries.py build +$PYTHON scripts/merge_built_libraries.py build diff --git a/build_ios_libs.sh b/build_ios_libs.sh index a95ff471..010656fc 100644 --- a/build_ios_libs.sh +++ b/build_ios_libs.sh @@ -1,6 +1,9 @@ set -e -python amalgamate.py +# Use python3 if available, otherwise fall back to python +PYTHON=$(command -v python3 >/dev/null 2>&1 && echo python3 || echo python) + +$PYTHON amalgamate.py rm -rf build mkdir build @@ -27,8 +30,8 @@ cd ../ HEADERS="amalgamated/pocketpy.h" -python scripts/merge_built_libraries.py build/os64 -python scripts/merge_built_libraries.py build/simulatorarm64 +$PYTHON scripts/merge_built_libraries.py build/os64 +$PYTHON scripts/merge_built_libraries.py build/simulatorarm64 xcodebuild -create-xcframework \ -library build/os64/libpocketpy.a -headers $HEADERS \ diff --git a/build_web.sh b/build_web.sh index 799f44c2..bd42019f 100644 --- a/build_web.sh +++ b/build_web.sh @@ -1,6 +1,9 @@ set -e -python prebuild.py +# Use python3 if available, otherwise fall back to python +PYTHON=$(command -v python3 >/dev/null 2>&1 && echo python3 || echo python) + +$PYTHON prebuild.py rm -rf web/lib mkdir web/lib diff --git a/cmake_build.py b/cmake_build.py index 954f9650..ac568da4 100644 --- a/cmake_build.py +++ b/cmake_build.py @@ -2,7 +2,7 @@ import os import sys import shutil -assert os.system("python prebuild.py") == 0 +assert os.system(f"{sys.executable} prebuild.py") == 0 if not os.path.exists("build"): os.mkdir("build") diff --git a/run_profile.sh b/run_profile.sh index 28cc8c37..9f1af0ec 100644 --- a/run_profile.sh +++ b/run_profile.sh @@ -1,6 +1,9 @@ set -e -python prebuild.py +# Use python3 if available, otherwise fall back to python +PYTHON=$(command -v python3 >/dev/null 2>&1 && echo python3 || echo python) + +$PYTHON prebuild.py SRC=$(find src/ -name "*.c") diff --git a/run_tests.sh b/run_tests.sh index 6b2c46ef..a5bb5ef6 100644 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,12 +1,15 @@ set -e -python prebuild.py +# Use python3 if available, otherwise fall back to python +PYTHON=$(command -v python3 >/dev/null 2>&1 && echo python3 || echo python) + +$PYTHON prebuild.py SRC=$(find src/ -name "*.c") clang -std=c11 --coverage -O1 -Wfatal-errors -o main src2/main.c $SRC -Iinclude -DPK_ENABLE_OS=1 -lm -ldl -DNDEBUG -python scripts/run_tests.py +$PYTHON scripts/run_tests.py # if prev error exit if [ $? -ne 0 ]; then diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 9232c7e7..245ee1ab 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -2,11 +2,14 @@ import os import sys import time import subprocess +import shutil def test_file(filepath, cpython=False): if cpython: - return os.system("python " + filepath) == 0 + # Use python3 if available, otherwise fall back to python + python_cmd = shutil.which("python3") or shutil.which("python") or "python" + return os.system(f"{python_cmd} {filepath}") == 0 if sys.platform == 'win32': code = os.system("main.exe " + filepath) else: