-
Notifications
You must be signed in to change notification settings - Fork 17
/
setup.py
executable file
·92 lines (73 loc) · 2.02 KB
/
setup.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
#! /usr/bin/env python
import os
import sys
import subprocess
import optparse
def main():
parser = optparse.OptionParser()
parser.add_option(
'--auto',
help="Disable interactive terminal input",
action="store_true",
default=False,
)
parser.add_option(
'--skipdeps',
help="Skip dependency installation",
action="store_true",
default=False,
)
(options, args) = parser.parse_args()
auto = options.auto
skip_deps = options.skipdeps
if not hasattr(sys, 'real_prefix'):
print("Not inside a virtualenv! Run")
print(" source bin/activate")
print("from the root directory of your site to enter the virtualenv")
return
project_path = os.path.dirname(os.path.abspath(__file__))
old_dir = os.getcwd()
try:
if not skip_deps:
install_dependencies(project_path)
copy_template_files(project_path)
os.chdir(project_path)
subprocess.check_call([
'python',
'manage.py',
'setup-dev',
])
finally:
os.chdir(old_dir)
def install_dependencies(project_path):
print("Installing dependencies...", file=sys.stderr)
delimit()
print("Installing compass...", file=sys.stderr)
subprocess.call([
'sudo',
'gem',
'install',
'compass',
])
print("Installing requirements...", file=sys.stderr)
subprocess.call([
'pip',
'install',
'-r',
os.path.join(project_path, 'requirements.txt'),
])
def copy_template_files(project_path):
os.chdir(os.path.join(project_path, 'hvz'))
print("Copying template files...", file=sys.stderr)
delimit()
if not os.path.exists('local_settings.py'):
print("local_settings.py...")
subprocess.call([
'cp',
'sample_local_settings.py',
'local_settings.py',
])
def delimit():
print("-" * 79, file=sys.stderr)
if __name__ == '__main__':
main()