Ajouter InstallLatestPython.sh

main
jeffrey 2025-01-20 11:11:33 +01:00
parent 382fab0d60
commit b2540d85fe
1 changed files with 30 additions and 0 deletions

30
InstallLatestPython.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Téléchargement des paquets nécessaires, pour la compilation
PKGS="pkg-config zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev"
apt install -y "$PKGS"
# Téléchargement des sources de la dernière version de python
rm -rf Python-* 2>/dev/null # Suppression d'éventuels relicats issus d'une installation précédente
L=`wget -q https://www.python.org/downloads/source/ -O - | gunzip | grep -oP '(?<=href="/)downloads/release/python-.+?(?=")' | head -n 1`
U="https://www.python.org/$L"
FIC=`wget -q -O - $U | gunzip | grep -oP '(?<=href=")https://www.python.org/ftp/python/.+tgz?(?=")' | head -n 1` # Récupération de l'url du fichier à télécharger
echo "Téléchargement de $FIC"
wget "$FIC"
# Extraction du fichier tgz
tar -xf `basename "$FIC"`
# Compilation + installation
DOSSIER=$(basename "$FIC" .tgz)
cd $DOSSIER
./configure --enable-optimizations
make
make install
cd ../
# Suppression du dossier d'extraction et du fichier tgz
rm -rf Python-* 2>/dev/null