Mercurial > hg > carton
comparison carton.py @ 23:987086aad234
stub adding carton to to virtualenv
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 08 Jul 2011 18:25:31 -0700 |
parents | 9c710f06e51d |
children | bb19d3dac4c5 |
comparison
equal
deleted
inserted
replaced
22:9c710f06e51d | 23:987086aad234 |
---|---|
48 ENV='''%(ENV)s''' | 48 ENV='''%(ENV)s''' |
49 | 49 |
50 # packed files | 50 # packed files |
51 VIRTUAL_ENV='''%(VIRTUAL_ENV)s'''.decode('base64').decode('zlib') | 51 VIRTUAL_ENV='''%(VIRTUAL_ENV)s'''.decode('base64').decode('zlib') |
52 PACKAGE_SOURCES=%(PACKAGE_SOURCES)s | 52 PACKAGE_SOURCES=%(PACKAGE_SOURCES)s |
53 CARTON=%(CARTON)s | |
53 | 54 |
54 # parse options | 55 # parse options |
55 usage = os.path.basename(sys.argv[0]) + ' [options]' | 56 usage = os.path.basename(sys.argv[0]) + ' [options]' |
56 parser = OptionParser(usage=usage, description=__doc__) | 57 parser = OptionParser(usage=usage, description=__doc__) |
57 parser.add_option('--env', dest='env', help="environment name [DEFAULT: " + ENV + "]") | 58 parser.add_option('--env', dest='env', help="environment name [DEFAULT: " + ENV + "]") |
118 setup_pys.add(i) | 119 setup_pys.add(i) |
119 | 120 |
120 # add virtualenv to the virtualenv (!) | 121 # add virtualenv to the virtualenv (!) |
121 virtualenv_dir = os.path.dirname(virtualenv) | 122 virtualenv_dir = os.path.dirname(virtualenv) |
122 if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')): | 123 if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')): |
123 call([python, 'setup.py', 'install'], cwd=virtualenv_dir) | 124 call([python, 'setup.py', 'install'], cwd=virtualenv_dir, stdout=subprocess.PIPE) |
124 | 125 |
125 # TODO: | 126 # TODO: |
127 | |
126 # - add carton to the virtualenv (!) | 128 # - add carton to the virtualenv (!) |
129 # if CARTON: | |
130 # CARTON = CARTON.decode('base64').decode('zlib') | |
131 # carton_filename = os.path.join(scripts_dir, 'carton.py') | |
132 # f = file(carton_filename, 'w') | |
133 # f.write(CARTON) | |
134 # f.close() | |
135 # try: | |
136 # os.chmod(carton_filename, 0755) | |
137 # except: | |
138 # # you probably don't have os.chmod | |
139 # pass | |
140 | |
127 # - cleanup tempdir | 141 # - cleanup tempdir |
128 # shutil.rmtree(tempdir) | 142 # shutil.rmtree(tempdir) |
129 """ | 143 """ |
130 | 144 |
131 def isURL(path): | 145 def isURL(path): |
212 else: | 226 else: |
213 globals()['VIRTUAL_ENV'] = urllib2.urlopen(virtualenv_url).read() | 227 globals()['VIRTUAL_ENV'] = urllib2.urlopen(virtualenv_url).read() |
214 # TODO: used the below hashed value of VIRTUAL_ENV if set | 228 # TODO: used the below hashed value of VIRTUAL_ENV if set |
215 # (set that with another file) | 229 # (set that with another file) |
216 | 230 |
231 # get the contents of this file | |
232 carton = None | |
233 try: | |
234 if __file__: | |
235 filename = __file__.rstrip('c') # avoid pyfiles | |
236 if os.path.exists(filename): | |
237 carton = file(filename).read().encode('zlib').encode('base64') | |
238 except NameError: | |
239 pass | |
240 | |
217 # interpolate "template" -> output | 241 # interpolate "template" -> output |
218 outfile = options.outfile | 242 outfile = options.outfile |
219 if outfile is None: | 243 if outfile is None: |
220 outfile = environment + '.py' | 244 outfile = environment + '.py' |
221 variables = {'VIRTUAL_ENV': VIRTUAL_ENV.encode('zlib').encode('base64'), | 245 variables = {'VIRTUAL_ENV': VIRTUAL_ENV.encode('zlib').encode('base64'), |
222 'ENV': environment, | 246 'ENV': environment, |
247 'CARTON': repr(carton), | |
223 'PACKAGE_SOURCES': repr(source_array)} | 248 'PACKAGE_SOURCES': repr(source_array)} |
224 f = file(outfile, 'w') | 249 f = file(outfile, 'w') |
225 f.write(template % variables) | 250 f.write(template % variables) |
226 f.close() | 251 f.close() |
227 try: | 252 try: |