-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython-install.sh
More file actions
executable file
·81 lines (64 loc) · 1.81 KB
/
Copy pathpython-install.sh
File metadata and controls
executable file
·81 lines (64 loc) · 1.81 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
#
# Copyright (C) 2020-2026 Joelle Maslak
# All Rights Reserved - See License
#
PYTHON310=3.10.20 # to be removed
PYTHON311=3.11.15
PYTHON312=3.12.13
PYTHON313=3.13.11
PYTHON314=3.14.2
PREFERRED="$PYTHON314"
doit() {
# Defensive umask
if [ "$(umask)" == '0000' ] ; then
umask 0002
fi
CWD=$(pwd)
# Install pyenv
if [ ! -d "$HOME/.pyenv" ] ; then
cd "$HOME" || echo >/dev/null
git clone https://github.com/yyuu/pyenv.git .pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
else
if ! command -v pyenv >/dev/null ; then
# pyenv not in path.
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
cd "$HOME/.pyenv/" && git pull && cd - || echo >/dev/null
fi
# Install pyenv-virtualenv
if [ ! -d "$HOME/.pyenv/plugins/pyenv-virtualenv" ] ; then
cd "$HOME/.pyenv/plugins" || echo >/dev/null
git clone https://github.com/yyuu/pyenv-virtualenv.git pyenv-virtualenv
fi
uninstall $PYTHON310
install $PYTHON311
install $PYTHON312
install $PYTHON313
install $PYTHON314
echo "Setting Python version to $PREFERRED"
pyenv global "$PREFERRED"
pyenv rehash
cd "$CWD" || echo >/dev/null
}
install() {
PYVER="$1"
PYVERREGEX=${PYVER//./\\.}
# Install python
if ! pyenv versions 2>/dev/null | egrep " $PYVERREGEX(\s.*)?$" >/dev/null ; then
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install "$PYVER"
fi
}
uninstall() {
PYVER="$1"
PYVERREGEX=${PYVER//./\\.}
if pyenv versions 2>/dev/null | egrep " $PYVERREGEX(\s.)?$" >/dev/null ; then
pyenv uninstall "$PYVER"
fi
}
doit "$@"