-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path40-python.sh
More file actions
61 lines (59 loc) · 1.76 KB
/
40-python.sh
File metadata and controls
61 lines (59 loc) · 1.76 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
# devnull@libcrack.so
# Sab ene 10 16:53:26 CET 2015
#
# Python stuff
## Toogle between python versions
python-toggle(){
test -z "$1" || v="$1"
local bins=('python' 'python-config' 'pip')
cd /usr/bin
for bin in ${bins[@]}; do
test -e $bin || {
echo -e "${RED}ERROR:${RESET} cannot find $PWD/$bin"
return 1
}
done
echo -e ">> ${RED}Disabled $(python -V 2>&1)${RESET}\007"
if [[ python -ef python3 || "python${v}" == "python3" ]]; then
sudo rm python python-config pip
sudo ln -s python2 python
sudo ln -s python2-config python-config
sudo ln -s pip2 pip
elif [[ python -ef python2 || "python${v}" == "python2" ]]; then
sudo rm python python-config pip
sudo ln -s python3 python
sudo ln -s python3-config python-config
sudo ln -s pip3 pip
else
echo -e "${RED}ERROR:${RESET} cannot find link /usr/bin/$bin"
cd - > /dev/null
return 2
fi
echo -e ">> ${GREEN}Enabled $(python -V 2>&1)${RESET}\007"
cd - > /dev/null
}
py2-enable(){ py-toggle 2; }
py3-enable(){ py-toggle 3; }
py-toggle(){ python-toggle ${@}; }
## Python virtual envs
# sudo pacman -S python2-virtualenv
# mkdir ~/.python
# cd ~/.python
# virtualenv2 27
# virtualenv3 33
python-venv(){
local activate=~/.python/$1/bin/activate
if [[ -e "$activate" ]]; then
echo -ne "${GREEN}>>${RESET} "
echo "Enabling python virtual env $activate"
source "$activate"
else
echo -ne "${RED}ERROR:${RESET} "
echo "Python virtual env not found: $activate"
fi
}
py-venv27() { py-venv 27 ; }
py-venv33() { py-venv 33 ; }
py-venv(){ python-venv ${@}; }
## Assemble the command "archlinux-java"
archlinux-python(){ python-toggle; }