Files
runner-images/images/linux/scripts/installers/python.sh
Mikhail Timofeev dd506183e2 [Ubuntu] Set user-related environmental variables and PATH via post deployment script (#3030)
* Move home directory vars to post-deploy scripts

* Remove "export" word

* Move home directory vars to post-deploy scripts

* Remove "export" word

* add variables via post-deployment file

* remove quotes around PATH

* remove quotes

* Replace $HOME in /etc/environment in post-deployment script

* rename variable

* get rid of extra variable
2021-03-26 18:33:51 +03:00

47 lines
1.4 KiB
Bash

#!/bin/bash -e
################################################################################
## File: python.sh
## Desc: Installs Python 2/3
################################################################################
set -e
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
source $HELPER_SCRIPTS/os.sh
# Install Python, Python 3, pip, pip3
if isUbuntu16 || isUbuntu18; then
apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip python3-venv
fi
if isUbuntu20; then
apt-get install -y --no-install-recommends python3 python3-dev python3-pip python3-venv
ln -s /usr/bin/pip3 /usr/bin/pip
fi
if isUbuntu18 || isUbuntu20 ; then
# 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
setEtcEnvironmentVariable "PIPX_BIN_DIR" $PIPX_BIN_DIR
setEtcEnvironmentVariable "PIPX_HOME" $PIPX_HOME
prependEtcEnvironmentPath $PIPX_BIN_DIR
# Test pipx
if ! command -v pipx; then
echo "pipx was not installed or not found on PATH"
exit 1
fi
fi
# Adding this dir to PATH will make installed pip commands are immediately available.
prependEtcEnvironmentPath '$HOME/.local/bin'
invoke_tests "Tools" "Python"