blob: 7b1fce54398a3cae162c896252b39ec9d71c8ce5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/env bash
set -euxo pipefail
shopt -s inherit_errexit
py_version="${1}"
# Install Python interpreter under e.g. /snekbin/python/3.13/ (no patch version)
# By dropping everything after, and including, the last period or hyphen.
install_path="${py_version%[-.]*}"
# Ensure the suffix letter is retained for free-threaded or JIT versions of Python.
if [[ $py_version == *t ]]; then
install_path+="t"
fi
if [[ $py_version == *j ]]; then
# Enable JIT mode when passed a version that ends with a "j"
install_path+="j"
py_version="${py_version%j}"
PYTHON_CONFIGURE_OPTS+=" --enable-experimental-jit"
fi
"${PYENV_ROOT}/plugins/python-build/bin/python-build" \
"${py_version}" \
"/snekbin/python/${install_path}"
"/snekbin/python/${install_path}/bin/python" -m pip install -U pip
# Clean up some unnecessary files to reduce image size bloat.
find /snekbin/python/ -depth \
\( \
\( -type d -a \( \
-name test -o -name tests -o -name idle_test \
\) \) \
-o \( -type f -a \( \
-name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \
\) \) \
\) -exec rm -rf '{}' +
|