compile-python/compile-python.sh

41 lines
1.3 KiB
Bash
Raw Normal View History

2021-12-07 11:14:15 +00:00
#!/bin/bash
2021-12-07 10:28:47 +00:00
compile-python()
{
# Inspired from the great https://gitlab.com/python-devs/ci-images/
# Thanks Barry Warsaw.
# Needs:
2023-06-21 16:11:24 +00:00
# sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
2021-12-07 10:28:47 +00:00
local PY_VERSION="$1"
local BETA="$2"
local URL="https://www.python.org/ftp/python"
(
2021-12-07 11:14:15 +00:00
cd /tmp || return 1
wget -qO- "$URL/$PY_VERSION/Python-$PY_VERSION$BETA.tgz" | tar -xzf - || (
2021-12-07 10:28:47 +00:00
echo "Version not found, check on $URL."
)
2023-06-21 16:11:24 +00:00
[ -d "Python-$PY_VERSION$BETA" ] && (cd "Python-$PY_VERSION$BETA"; ./configure --prefix="$HOME/.local/" && make -j "$(nproc)" && make altinstall) &&
2021-12-07 11:14:15 +00:00
rm -r "Python-$PY_VERSION$BETA"
2021-12-07 10:28:47 +00:00
)
}
compile-pythons()
{
# Compiles a usefull set of Python versions.
2023-06-07 09:41:49 +00:00
compile-python 3.7.17 &
compile-python 3.8.18 &
compile-python 3.9.18 &
compile-python 3.10.13 &
compile-python 3.11.5 &
compile-python 3.12.0 rc2 &
2021-12-07 10:28:47 +00:00
wait
}
_compile_python()
{
COMPREPLY=( $( compgen -W '$( command curl -s https://www.python.org/ftp/python/ | grep -o ">[0-9.]\+/<" | sed "s/^>//;s|/<$||" )' -- "${COMP_WORDS[COMP_CWORD]}") )
}
complete -F _compile_python compile-python