Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (98 sloc) 3.775 kB
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
1 """
2 Call this like ``python fassembler/create-venv-script.py``; it will
3 refresh the fassembler-boot.py script
4 """
5 import os
6 import subprocess
7 import re
8
9 here = os.path.dirname(os.path.abspath(__file__))
10 base_dir = os.path.dirname(here)
11 script_name = os.path.join(base_dir, 'fassembler-boot.py')
12
13 import virtualenv
14
15 EXTRA_TEXT = """
99b7e9d @ejucovy * Move Fassembler from SVN to Git, default location in Github
ejucovy authored
16 FASS_GIT_LOCATION = "git://github.com/socialplanning/fassembler.git"
643136f @ianb use more dynamic svn location finder (could be a model for building b…
ianb authored
17
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
18 import shutil
19
836f405 @ianb Add a --svn option to fassembler-boot, so you can use an existing che…
ianb authored
20 def extend_parser(parser):
21 parser.add_option(
99b7e9d @ejucovy * Move Fassembler from SVN to Git, default location in Github
ejucovy authored
22 '--git',
23 dest='fassembler_git',
24 default=FASS_GIT_LOCATION,
25 help='Location of a git repository to use for the installation of fassembler')
836f405 @ianb Add a --svn option to fassembler-boot, so you can use an existing che…
ianb authored
26
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
27 def adjust_options(options, args):
91d19af @k0s fix the problem, not the symptom
k0s authored
28 if not args:
29 return # caller will raise error
30
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
31 # We're actually going to build the venv in a subdirectory
32 base_dir = args[0]
33 args[0] = join(base_dir, 'fassembler')
34
35 def after_install(options, home_dir):
36 base_dir = os.path.dirname(home_dir)
37 src_dir = join(home_dir, 'src')
99b7e9d @ejucovy * Move Fassembler from SVN to Git, default location in Github
ejucovy authored
38 fassembler_git = options.fassembler_git
39
40 fassembler_dir = join(src_dir, 'fassembler')
41 call_subprocess(['rm', '-rf', fassembler_dir])
42
43 logger.notify('Installing fassembler from %s to %s' % (fassembler_git, fassembler_dir))
44 fs_ensure_dir(src_dir)
45 call_subprocess(['git', 'clone', fassembler_git, fassembler_dir],
46 show_stdout=True)
836f405 @ianb Add a --svn option to fassembler-boot, so you can use an existing che…
ianb authored
47 logger.indent += 2
48 try:
8fd5c53 @ejucovy svn.openplans.org/eggs has a 1.2.2 mysql-python egg which we don't wa…
ejucovy authored
49 call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), 'mysql-python'],
3bd40df @jab unbreak create-venv-script
jab authored
50 cwd=os.path.abspath(fassembler_dir),
51 filter_stdout=filter_python_develop,
52 show_stdout=False)
53 call_subprocess([os.path.abspath(join(home_dir, 'bin', 'python')), 'setup.py', 'develop'],
836f405 @ianb Add a --svn option to fassembler-boot, so you can use an existing che…
ianb authored
54 cwd=os.path.abspath(fassembler_dir),
55 filter_stdout=filter_python_develop,
56 show_stdout=False)
57 finally:
58 logger.indent -= 2
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
59 script_dir = join(base_dir, 'bin')
60 script_dest = join(script_dir, 'fassembler')
61 logger.notify('Copying fassembler to %s' % script_dest)
62 fs_ensure_dir(script_dir)
99b7e9d @ejucovy * Move Fassembler from SVN to Git, default location in Github
ejucovy authored
63 if os.path.exists(script_dest):
64 os.unlink(script_dest)
3a9a3a0 @ianb Make the boot script create a symlink for bin/fassembler instead of a…
ianb authored
65 os.symlink('../fassembler/bin/fassembler', script_dest)
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
66 etc_dir = join(base_dir, 'etc')
67 build_ini = join(etc_dir, 'build.ini')
68 if not os.path.exists(build_ini):
69 fs_ensure_dir(etc_dir)
70 logger.notify('Touching %s' % build_ini)
71 f = open(build_ini, 'w')
72 f.close()
73 logger.notify('Run "%s fassembler:topp" (etc) to build out the environment'
74 % script_dest)
75 logger.notify('Run "%s Package" to install new packages that provide builds'
76 % join(home_dir, 'bin', 'easy_install'))
77
78 def fs_ensure_dir(dir):
79 if not os.path.exists(dir):
80 logger.info('Creating directory %s' % dir)
81 os.makedirs(dir)
82
83 def filter_python_develop(line):
84 if not line.strip():
85 return Logger.DEBUG
86 for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ',
87 'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ',
88 'creating ', 'Copying ']:
89 if line.startswith(prefix):
90 return Logger.DEBUG
836f405 @ianb Add a --svn option to fassembler-boot, so you can use an existing che…
ianb authored
91 return Logger.NOTIFY
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
92 """
93
94 def main():
8b7a6dc @ianb updated fassembler-boot again to match virtualenv change
ianb authored
95 text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version='2.4')
0a3ce17 @ianb Added a boot script for fassembler
ianb authored
96 if os.path.exists(script_name):
97 f = open(script_name)
98 cur_text = f.read()
99 f.close()
100 else:
101 cur_text = ''
102 print 'Updating %s' % script_name
103 if cur_text == 'text':
104 print 'No update'
105 else:
106 print 'Script changed; updating...'
107 f = open(script_name, 'w')
108 f.write(text)
109 f.close()
110
111 if __name__ == '__main__':
112 main()
113
Something went wrong with that request. Please try again.