-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_python.sh
54 lines (41 loc) · 1.39 KB
/
install_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
52
53
54
#!/bin/bash
# [USAGE]
# sudo bash setup.sh [test]
set -e
TEST_FLAG=$1
### Install Python 3 from source
# Install compiling dependencies
echo "[INFO] Downloading Python installation dependencies..."
apt -y install libssl-dev libffi-dev
# Latest Python version
PYTHON_VERSION=3.12.4
# Get source from the internet
echo "[INFO] Downloading Python release ${PYTHON_VERSION}..."
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
# Extract and cd to Python sources dir.
echo "[INFO] Extracting release source files..."
tar -xf Python-${PYTHON_VERSION}.tar.xz
cd Python-${PYTHON_VERSION}
# Checks for installation requirements
echo "[INFO] Validating installation requirements for Python release..."
./configure
# Compile sources into objects
echo "[INFO] Preparing Python release for install..."
make
# Optional, it may not finish via SSH
if [ "${TEST_FLAG}" = "test" ]
then
echo "[INFO] Testing Python release..."
make test
fi
# Puts binaries together
# make altinstall => installs the downloaded release as an alternative one
# make install => installs the downloaded release as the main one for the system
echo "[INFO] Installing Python release..."
make altinstall
# Clean up temporary files.
echo "[INFO] Python ${PYTHON_VERSION} installed successfully!"
echo "[INFO] Cleaning up files..."
cd ..
rm -r Python-${PYTHON_VERSION}
rm Python-${PYTHON_VERSION}.tar.xz