forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile-development.py
75 lines (55 loc) · 2.1 KB
/
fabfile-development.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
from fabric.api import cd, env, prefix, run, sudo, task
# Fill out USER and HOSTS configuration before running
env.user = ''
env.hosts = ['']
env.code_dir = '/home/%s/rtd/checkouts/readthedocs.org' % (env.user)
env.virtualenv = '/home/%s/rtd' % (env.user)
def install_prerequisites():
"""Install prerequisites."""
sudo("apt-get -y install python-dev python-pip git redis-server texlive "
"texlive-latex-extra")
sudo("pip install virtualenv")
def create_virtualenv():
"""Create virtualenv."""
run("virtualenv --no-site-packages --distribute rtd")
def clone_repository():
"""Clone readthedocs repo"""
run("mkdir %s/checkouts" % (env.virtualenv))
with cd("%s/checkouts" % env.virtualenv):
run("git clone http://github.com/rtfd/readthedocs.org.git")
def pip_requirements():
"""Install pip requirements"""
with cd(env.code_dir):
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("pip install -r pip_requirements.txt")
def build_db():
"""Build database"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("%s/readthedocs/manage.py syncdb" % (env.code_dir))
def migrate_db():
"""Migrate database"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("%s/readthedocs/manage.py migrate" % (env.code_dir))
def load_testprojects():
"""Load test data and update repos"""
with prefix("source %s/bin/activate" % (env.virtualenv)):
run("%s/readthedocs/manage.py loaddata test_data" % (env.code_dir))
run("%s/readthedocs/manage.py update_repos" % (env.code_dir))
@task(default=True)
def install():
"""Install readthedocs"""
install_prerequisites()
create_virtualenv()
clone_repository()
pip_requirements()
build_db()
migrate_db()
load_testprojects()
@task
def clean():
"""Clean up everything to start over"""
sudo("rm -rf %s" % (env.virtualenv))
sudo("pip uninstall virtualenv")
sudo("apt-get -y purge python-dev python-pip git redis-server texlive "
"texlive-latex-extra")
sudo("apt-get -y autoremove --purge")