2020-10-07 13:49:40 +05:00
|
|
|
#!/bin/bash -e
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
## File: python.sh
|
2019-12-16 13:47:05 -05:00
|
|
|
## Desc: Installs Python 2/3
|
2019-12-13 09:48:00 -05:00
|
|
|
################################################################################
|
|
|
|
|
|
2020-09-30 16:19:28 +03:00
|
|
|
set -e
|
2019-12-13 09:48:00 -05:00
|
|
|
# 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
|
2019-12-13 09:48:00 -05:00
|
|
|
|
|
|
|
|
# Install Python, Python 3, pip, pip3
|
2020-09-30 16:59:28 +03:00
|
|
|
if isUbuntu16 || isUbuntu18; then
|
2020-10-01 17:52:16 +03:00
|
|
|
apt-get install -y --no-install-recommends python python-dev python-pip python3 python3-dev python3-pip python3-venv
|
2020-05-26 18:45:48 +03:00
|
|
|
fi
|
2019-12-13 09:48:00 -05:00
|
|
|
|
2020-09-30 16:59:28 +03:00
|
|
|
if isUbuntu20; then
|
2020-10-01 17:52:16 +03:00
|
|
|
apt-get install -y --no-install-recommends python3 python3-dev python3-pip python3-venv
|
2020-09-30 16:19:28 +03:00
|
|
|
ln -s /usr/bin/pip3 /usr/bin/pip
|
|
|
|
|
fi
|
|
|
|
|
|
2020-10-05 09:20:26 +03:00
|
|
|
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
|
2020-10-05 11:08:22 +03:00
|
|
|
prependEtcEnvironmentPath $PIPX_BIN_DIR
|
2020-10-05 09:20:26 +03:00
|
|
|
|
|
|
|
|
# Test pipx
|
|
|
|
|
if ! command -v pipx; then
|
|
|
|
|
echo "pipx was not installed or not found on PATH"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2020-10-01 17:52:16 +03:00
|
|
|
|
2019-12-13 09:48:00 -05:00
|
|
|
# Run tests to determine that the software installed as expected
|
|
|
|
|
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
2020-10-05 09:20:26 +03:00
|
|
|
for cmd in python pip python3 pip3; do
|
2019-12-13 09:48:00 -05:00
|
|
|
if ! command -v $cmd; then
|
|
|
|
|
echo "$cmd was not installed or not found on PATH"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|