Files
runner-images/images/ubuntu/scripts/build/install-python.sh
T

46 lines
1.2 KiB
Bash
Raw Normal View History

2020-10-07 13:49:40 +05:00
#!/bin/bash -e
################################################################################
2023-11-22 21:49:23 +01:00
## File: install-python.sh
## Desc: Install Python 3
################################################################################
2020-09-30 16:19:28 +03:00
set -e
# Source the helpers for use with the script
2020-10-03 11:54:36 +03:00
source $HELPER_SCRIPTS/etc-environment.sh
2020-05-26 18:45:48 +03:00
source $HELPER_SCRIPTS/os.sh
# Install Python, Python 3, pip, pip3
2024-05-29 13:43:07 +02:00
apt-get install --no-install-recommends python3 python3-dev python3-pip python3-venv
2020-09-30 16:19:28 +03:00
if is_ubuntu24; then
# Create temporary workaround to allow user to continue using pip
sudo cat <<EOF > /etc/pip.conf
[global]
break-system-packages = true
EOF
fi
# Install pipx
# Set pipx custom directory
export PIPX_BIN_DIR=/opt/pipx_bin
export PIPX_HOME=/opt/pipx
python3 -m pip install pipx
python3 -m pipx ensurepath
# Update /etc/environment
2023-12-26 12:50:52 +01:00
set_etc_environment_variable "PIPX_BIN_DIR" $PIPX_BIN_DIR
set_etc_environment_variable "PIPX_HOME" $PIPX_HOME
prepend_etc_environment_path $PIPX_BIN_DIR
2023-12-29 12:36:27 +01:00
# Test pipx
if ! command -v pipx; then
echo "pipx was not installed or not found on PATH"
exit 1
2020-10-05 09:20:26 +03:00
fi
2020-10-01 17:52:16 +03:00
# Adding this dir to PATH will make installed pip commands are immediately available.
2023-12-26 12:50:52 +01:00
prepend_etc_environment_path '$HOME/.local/bin'
invoke_tests "Tools" "Python"