-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_env.py
66 lines (57 loc) · 1.53 KB
/
init_env.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
#!/usr/bin/env python
"""
This script initializes your environment to work the way it should.
"""
import os, sys
import subprocess
import shutil
from deployment.deploy import to_setup, to_fetch
from os.path import join
USAGE = """
Without arguments, just sets environment variables. Run with -i to install
necessary packages
"""
def setup_env_variables():
"""
Sets the appropriate environment variables.
"""
ENV_SH = '/var/local/rubicon_env.sh'
if os.path.exists(ENV_SH) and \
not os.environ.has_key('PRODUCTION'):
brc = open('~/.bashrc', 'a')
brc.write('source %s' % ENV_SH)
brc.close()
os.system('source %s' % ENV_SH)
def create_dev_env():
"""
Installs all the software necessary to develop.
"""
repo = os.path.abspath(os.curdir)
for package in to_fetch:
try:
os.system(package[1])
os.chdir(join(repo, package[0]))
subprocess.check_call([
'python', 'setup.py', 'install'
])
finally:
os.chdir(repo)
try:
shutil.rmtree(package[0])
except Exception:
pass
for package in to_setup:
os.chdir(join(repo, package))
subprocess.check_call([
'python',
'setup.py',
'develop'
])
def main():
if '-h' in sys.argv or '--help' in sys.argv:
print USAGE
sys.exit(0)
setup_env_variables()
create_dev_env()
if __name__ == '__main__':
main()