-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-python.sh
More file actions
executable file
·54 lines (44 loc) · 1.17 KB
/
install-python.sh
File metadata and controls
executable file
·54 lines (44 loc) · 1.17 KB
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
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_NAME="$(basename "$0")"
export DEBIAN_FRONTEND=noninteractive
log() { printf '[*] %s\n' "$*"; }
warn() { printf '[!] %s\n' "$*" >&2; }
die() { printf '[x] %s\n' "$*" >&2; exit 1; }
trap 'warn "Erreur à la ligne ${BASH_LINENO[0]}: commande '\''${BASH_COMMAND}'\''"' ERR
usage() {
cat <<EOF
Usage:
sudo bash $SCRIPT_NAME
Ce script :
- installe Python 3, pip, venv, dev headers
- installe pipx pour les outils CLI isolés
EOF
}
require_root() {
[[ "${EUID}" -eq 0 ]] || die "Ce script doit être exécuté en root."
}
main() {
require_root
log "Installation de Python 3 + outils"
apt-get update
apt-get install -y \
python3 \
python3-pip \
python3-venv \
python3-dev \
python3-setuptools \
python3-wheel \
pipx
log "Configuration de pipx dans le PATH system-wide"
cat > /etc/profile.d/pipx.sh <<'PROFILE'
if [[ -d "${HOME}/.local/bin" ]]; then
export PATH="${HOME}/.local/bin:${PATH}"
fi
PROFILE
chmod 0644 /etc/profile.d/pipx.sh
log "Python installé avec succès."
python3 --version
pip3 --version 2>/dev/null || true
}
main "$@"