-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_python.sh
51 lines (36 loc) · 1.17 KB
/
update_python.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Update Python on Raspberry Pi
# Used for getting Python3 on Buster Lite
PY_VERSION="3.9.1"
PY_URL="https://www.python.org/ftp/python/${PY_VERSION}/Python-${PY_VERSION}.tgz"
TEMP_DIR="$(mktemp -d)"
CUR_DIR="$(pwd)"
if [[ ! "$TEMP_DIR" || ! -d "$TEMP_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
function cleanup {
rm -rf "$TEMP_DIR"
echo "Deleted temp working directory $TEMP_DIR"
}
trap cleanup EXIT
echo "Installing Python $PY_VERSION"
read -p "Press Enter to continue..."
# Install dependencies to build
sudo apt install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev checkinstall
# Download Python tar
echo "Now downloading Python $PY_VERSION"
echo "From: $PY_URL"
read -p "Press Enter to continue..."
cd $TEMP_DIR
wget ${PY_URL} -O ${TEMP_DIR}/python.tgz
# Extract from tar
tar -xzvf python.tgz
cd "Python-$PY_VERSION"
# configure, make, install
echo "Will now make and install"
read -p "Press enter to continue..."
./configure --enable-optimizations
make
sudo make install
echo "Python v${PY_VERSION} installed!"
cd $CUR_DIR