forked from utahta/pythonbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonbrew-install
More file actions
executable file
·124 lines (90 loc) · 2.42 KB
/
pythonbrew-install
File metadata and controls
executable file
·124 lines (90 loc) · 2.42 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
PYTHON=`command -v python`
usage()
{
printf "
Usage:
${0} [options]
options:
--python : Python interpreter.
"
}
parse_arguments()
{
for arg do
val=`echo "$arg" | sed -e "s;--[^=]*=;;"`
case "$arg" in
--python=*) PYTHON="$val" ;;
--help) usage ;;
*) echo "Can't find the option. :$arg";;
esac
done
}
parse_arguments $@
if [[ ! -x $PYTHON ]] ; then
echo "I think $PYTHON is not Python interpreter."
exit
fi
PYTHON_VERSION=`$PYTHON -V 2>&1`
PYTHON_VERSION=${PYTHON_VERSION/"Python "/""}
PYTHON_VERSION_S=`echo $PYTHON_VERSION | sed -e "s/\(^[[:digit:]]\{1,\}.[[:digit:]]\{1,\}\).*/\1/"`
if [[ $PYTHON_VERSION_S != "2.4" ]] && [[ $PYTHON_VERSION_S != "2.5" ]] && [[ $PYTHON_VERSION_S != "2.6" ]] ; then
printf "Python's version is $PYTHON_VERSION_S:
2.4 <= python < 3.0 is required.
"
exit
fi
ROOT="$HOME/.pythonbrew"
if [[ -n $PYTHONBREW_ROOT ]] ; then
ROOT=$PYTHONBREW_ROOT
fi
PATH_DISTS="$ROOT/dists"
PATH_ETC="$ROOT/etc"
mkdir -p $PATH_DISTS
rm -rf $PATH_DISTS/pythonbrew.tar.gz
rm -rf $PATH_DISTS/utahta-pythonbrew*
TEMP_TARBALL="pythonbrew.tar.gz"
DOWNLOAD_URL="http://github.com/utahta/pythonbrew/tarball/master"
echo "Downloading $DOWNLOAD_URL"
builtin cd $PATH_DISTS ; curl -L $DOWNLOAD_URL -o "$TEMP_TARBALL" > /dev/null 2>&1
echo "Extracting $PATH_DISTS/$TEMP_TARBALL"
builtin cd $PATH_DISTS ; tar zxf $TEMP_TARBALL
TEMP_FILE=`ls $PATH_DISTS | grep utahta-pythonbrew`
echo "Installing pythonbrew into $ROOT"
$PYTHON $PATH_DISTS/$TEMP_FILE/pythonbrew_install.py
if [[ $? == 1 ]] ; then
echo "Failed to install pythonbrew."
exit
fi
case $SHELL in
*tcsh)
shrc="cshrc"
yourshrc="tcshrc"
;;
*csh)
shrc="cshrc"
yourshrc=$shrc
;;
*)
shrc="bashrc"
yourshrc=$shrc
;;
esac
printf "
The pythonbrew is installed as:
$ROOT/bin/pythonbrew
You may trash the downloaded $0 from now on.
Pythonbrew environment initiated, required directories are created under
$ROOT
Well-done! Congratulations! Please add the following line to the end
of your ~/.$yourshrc
source $PATH_ETC/$shrc
After that, exit this shell, start a new one, and install some fresh
pythons:
pythonbrew install 2.6.6
pythonbrew install 2.5.5
For further instructions, run:
pythonbrew help
The default help messages will popup and tell you what to do!
Enjoy pythonbrew at $ROOT!!
"