-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_python3.sh
38 lines (32 loc) · 1.17 KB
/
install_python3.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
#!/usr/bin/env bash
# Build Python 3 from source and install it.
# Usage: install_python3
set -e
VERSION="3.7.9"
DOWNLOAD_URL="https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz"
echo "Downloading Python ${VERSION} source code"
apt-get update && apt-get install -y \
software-properties-common build-essential curl wget \
libexpat1-dev libssl-dev zlib1g-dev \
libncurses5-dev libbz2-dev liblzma-dev \
dpkg-dev libreadline-dev libsqlite3-dev \
libffi-dev tcl-dev libgdbm-dev bluez libbluetooth-dev libglib2.0-dev \
python3-dev python3-tk libboost-python-dev libboost-thread-dev tk-dev
wget -O python.tar.tgz "${DOWNLOAD_URL}"
echo "Building Python ${VERSION}"
tar -zxf python.tar.tgz
cd "Python-${VERSION}"
./configure \
--enable-shared \
--enable-optimizations \
--enable-loadable-sqlite-extensions \
--enable-ipv6 \
--with-assertions \
--with-lto
make -j $(nproc)
make altinstall
update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.7 37
update-alternatives --install /usr/local/bin/python3 python3 /usr/local/bin/python3.7 37
ldconfig
echo 'Installing the latest version of pip3'
curl "https://bootstrap.pypa.io/get-pip.py" | python