-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_python.sh
More file actions
executable file
·37 lines (30 loc) · 1.15 KB
/
install_python.sh
File metadata and controls
executable file
·37 lines (30 loc) · 1.15 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
#!/bin/bash
set -e
BASH_POST="${HOME}/.bash_post"
if ! command -v pyenv >/dev/null 2>&1; then
echo "[error] pyenv is not installed or not available in PATH."
echo "[info] Install pyenv first, for example:"
echo "[info] curl -fsSL https://pyenv.run | bash"
echo "[info] Then add pyenv to your shell startup and run this script again."
echo "[info] See: https://github.com/pyenv/pyenv?tab=readme-ov-file#installation"
exit 1
fi
touch "${BASH_POST}"
export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init - bash)"
if ! grep -sq 'pyenv init - bash' "${BASH_POST}"; then
echo "[info] Adding pyenv configuration to .bash_post"
cat <<-'EOF' >> "${BASH_POST}"
# ============================================================================
# pyenv
# ============================================================================
export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:${PATH}"
eval "$(pyenv init - bash)"
EOF
fi
echo ""
echo "[info] Done."
echo "[info] Use 'pyenv install <version>' to install a Python version."
echo "[info] Use 'pyenv global <version>' or 'pyenv local <version>' to select it."