Skip to content

Commit a52998c

Browse files
committed
Use extracted Python interpreter for compileall
Look up and use the Python binary from the extracted runtime (bin/python<VERSION>, then bin/python3, then bin/python) when running compileall. Fail with an error if no interpreter is found, and invoke compileall with -I to avoid importing site-packages. This makes the build use the bundled interpreter instead of relying on a system python.
1 parent 47a594c commit a52998c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

linux/package-for-linux.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ mkdir -p $PYTHON_ARCH/build
2121
tar zxvf $DIST_FILE -C $PYTHON_ARCH/build
2222

2323
# compile lib
24-
python -m compileall -b "$PYTHON_ARCH/build/python/lib/python$PYTHON_VERSION_SHORT"
24+
build_python="$PYTHON_ARCH/build/python/bin/python$PYTHON_VERSION_SHORT"
25+
if [ ! -x "$build_python" ]; then
26+
build_python="$PYTHON_ARCH/build/python/bin/python3"
27+
fi
28+
if [ ! -x "$build_python" ]; then
29+
build_python="$PYTHON_ARCH/build/python/bin/python"
30+
fi
31+
if [ ! -x "$build_python" ]; then
32+
echo "Python interpreter not found in extracted runtime under $PYTHON_ARCH/build/python/bin"
33+
exit 1
34+
fi
35+
"$build_python" -I -m compileall -b "$PYTHON_ARCH/build/python/lib/python$PYTHON_VERSION_SHORT"
2536

2637
# copy build to dist
2738
mkdir -p $PYTHON_ARCH/dist

0 commit comments

Comments
 (0)