mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
Fix amalgamation script to work with python3-only environments (#444)
- Use sys.executable in Python scripts (amalgamate.py, cmake_build.py) instead of hardcoded 'python' - Update shell scripts to prefer python3 over python with fallback - Fix scripts/run_tests.py to detect python3 for CPython benchmarking This fixes the issue where the amalgamation script fails on Linux systems that only have python3 available and no 'python' symlink.
This commit is contained in:
parent
1e2135e153
commit
c7572c76ba
@ -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']
|
||||
|
||||
2
build.sh
2
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."
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 \
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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")
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user