-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_installer.sh
More file actions
100 lines (85 loc) · 2.62 KB
/
Copy pathpython_installer.sh
File metadata and controls
100 lines (85 loc) · 2.62 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Python 3 and Pip Installer for USB Slots by Xan#7777
# This installs python 3, pip and pyenv on your slot using pyenv
# After installing, close your SSH and login again for profile to properly load.
# Unofficial Script warning
clear
echo "This is the Python and PIP Installer!"
echo ""
printf "\033[0;31mDisclaimer: This installer is unofficial and USB staff will not support any issues with it\033[0m\n"
read -r -p "Type confirm if you wish to continue: " input
if [ ! "$input" = "confirm" ]
then
exit
fi
# Install pyenv
echo "Installing pyenv..."
sleep 1
curl https://pyenv.run | bash
# Add pyenv to bashrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
# Load new bashrc
# shellcheck disable=SC1091
source "$HOME"/.bashrc
source "$HOME"/.profile
# Install xxenv-latest
git clone https://github.com/momo-lab/xxenv-latest.git "$(pyenv root)"/plugins/pyenv-latest
# Python Version Chooser
clear
echo "Choose between 3.6, 3.7, 3.8, or latest."
echo "1 = Python 3.6"
echo "2 = Python 3.7"
echo "3 = Python 3.8"
echo "4 = Latest Python 3 release"
echo "5 = Python 2.7"
echo "We recommend using Python 3.8 as your default Python version."
while true; do
read -r -p "Enter your response here: " pyver
case $pyver in
1)
"$HOME"/.pyenv/bin/pyenv latest install 3.6 -v
break
;;
2)
"$HOME"/.pyenv/bin/pyenv latest install 3.7 -v
break
;;
3)
"$HOME"/.pyenv/bin/pyenv latest install 3.8 -v
break
;;
4)
"$HOME"/.pyenv/bin/pyenv latest install -v
break
;;
5)
"$HOME"/.pyenv/bin/pyenv latest install 2.7 -v
break
;;
*)
echo "Unknown response. Try again..."
;;
esac
done
# Check Python
clear
"$HOME"/.pyenv/bin/pyenv latest global
echo "Getting python version..."
command -v python
python -m pip -V
sleep 2
# Updating all pip packages
echo "Updating all pip packages..."
"$(command -v python)" -m pip list --outdated --format=freeze | grep -v "^\-e" | cut -d = -f 1 | xargs -n1 "$(command -v python)" -m pip install -U pip
# Replacing PATH
sed -i -e 's|PATH="$HOME/bin:$PATH"|PATH="$HOME/bin:$HOME/.local/bin:$PATH"|g' "$HOME"/.profile
# Reload new profile
# shellcheck disable=SC1091
source "$HOME"/.profile
# Cleanup, reload shell and Exit
clear
echo "Done. Run the following command to properly load up your Python/Pip Install."
echo " exec $SHELL "
exit