aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2023-08-29 19:35:53 +0100
committerGravatar GitHub <[email protected]>2023-08-29 19:35:53 +0100
commitf85116ab91229d3f45a8292978ffd2af7821c70e (patch)
treeff08fbd7ee351092948eca109b320d99f05338a1 /scripts
parentMerge pull request #183 from python-discord/enforce-filesize-limits (diff)
parentInstall eval dependencies with --user & ensure user base var is set (diff)
Merge pull request #181 from python-discord/feat/158/multi-version
Install Multiple Python Versions in the Image
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_python.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/build_python.sh b/scripts/build_python.sh
new file mode 100755
index 0000000..da937c2
--- /dev/null
+++ b/scripts/build_python.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -euxo pipefail
+shopt -s inherit_errexit
+
+py_version="${1}"
+
+# Install Python interpreter under e.g. /lang/python/3.11/ (no patch version).
+"${PYENV_ROOT}/plugins/python-build/bin/python-build" \
+ "${py_version}" \
+ "/lang/python/${py_version%.*}"
+"/lang/python/${py_version%.*}/bin/python" -m pip install -U pip
+
+# Clean up some unnecessary files to reduce image size bloat.
+find /lang/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 '{}' +