blob: d026eb893716dd263776a7f7c5fdb2c9b48947e5 (
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
|
#!/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%[-.]*}"
# If python version ends with a t, then ensure Python is installed to a dir ending with a t.
if [[ $py_version == *t ]]; then
install_path+="t"
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 '{}' +
|