-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.py
92 lines (75 loc) · 2.74 KB
/
installer.py
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
from fabric.api import run, cd, put, sudo
from fabric.contrib.files import exists, contains, append
from fabric.decorators import runs_once
@runs_once
def install():
"""Install environments"""
install_requirements()
install_pyenv()
install_python()
install_mysql_connector_python()
install_kawaz()
@runs_once
def install_pyenv():
"""Install and configure the pyenv to make it ready"""
# install pyenv via pyenv-installer
run("curl -L "
"https://raw.githubusercontent.com/yyuu/"
"pyenv-installer/master/bin/pyenv-installer | bash")
if not exists('~/.bash_profile_pyenv'):
# push .bash_profile_pyenv
import os
base_dir = os.path.dirname(__file__)
put(os.path.join(base_dir, 'statics', '.bash_profile_pyenv'),
'~/.bash_profile_pyenv')
if not contains('~/.bash_profile',
'source "$HOME/.bash_profile_pyenv"'):
# add source line
append('~/.bash_profile', 'source "$HOME/.bash_profile_pyenv"')
@runs_once
def install_python():
run("pyenv install 3.4.0 --skip-existing")
run("pyenv virtualenv 3.4.0 Kawaz --clear --force")
run("pyenv global Kawaz")
@runs_once
def install_requirements():
sudo("aptitude install -y git")
# requirements of pyenv
sudo("aptitude install -y "
"make build-essential libssl-dev zlib1g-dev libbz2-dev "
"libreadline-dev libsqlite3-dev wget curl llvm")
# requirements of Pillow
sudo("aptitude install -y "
"libjpeg-dev zlib1g-dev libtiff-dev libfreetype6-dev libwebp-dev"
"libopenjpeg-dev")
@runs_once
def install_kawaz():
if exists('~/Kawaz'):
run("rm -rf ~/Kawaz")
run("git clone https://github.com/kawazrepos/Kawaz3rd ~/Kawaz")
with cd("~/Kawaz"):
run("git pull --force")
run("pip install 'django==1.6'")
run("pip install -r requirements.txt")
run("pip install -r requirements-test.txt")
@runs_once
def install_mysql_connector_python(version="1.2.2"):
"""
Install mysql-connector-python to the local system.
fabric deploy command should call this command as
>>> run("fab install_mysql_connector_python")
"""
import tempfile
BASE_FILENAME = "mysql-connector-python-{}.tar.gz"
BASE_DIRNAME = "mysql-connector-python-{}"
BASE_URL = "http://cdn.mysql.com//Downloads/Connector-Python/{}"
# create temporary directory
tmpdir = tempfile.mkdtemp()
filename = BASE_FILENAME.format(version)
dirname = BASE_DIRNAME.format(version)
url = BASE_URL.format(filename)
with cd(tmpdir):
run("curl {} -o {}".format(url, filename))
run("tar zxvf {}".format(filename))
run("pip install ./{}".format(dirname))
run("rm -rf {}".format(tmpdir))