# HG changeset patch # User Jeff Hammel # Date 1310174731 25200 # Node ID 987086aad2348e21a6d02c35057a1cd4f556026e # Parent 9c710f06e51de029f365334ba19d7c690edfb0f7 stub adding carton to to virtualenv diff -r 9c710f06e51d -r 987086aad234 carton.py --- a/carton.py Fri Jul 08 18:11:09 2011 -0700 +++ b/carton.py Fri Jul 08 18:25:31 2011 -0700 @@ -50,6 +50,7 @@ # packed files VIRTUAL_ENV='''%(VIRTUAL_ENV)s'''.decode('base64').decode('zlib') PACKAGE_SOURCES=%(PACKAGE_SOURCES)s +CARTON=%(CARTON)s # parse options usage = os.path.basename(sys.argv[0]) + ' [options]' @@ -120,10 +121,23 @@ # add virtualenv to the virtualenv (!) virtualenv_dir = os.path.dirname(virtualenv) if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')): - call([python, 'setup.py', 'install'], cwd=virtualenv_dir) + call([python, 'setup.py', 'install'], cwd=virtualenv_dir, stdout=subprocess.PIPE) # TODO: + # - add carton to the virtualenv (!) +# if CARTON: +# CARTON = CARTON.decode('base64').decode('zlib') +# carton_filename = os.path.join(scripts_dir, 'carton.py') +# f = file(carton_filename, 'w') +# f.write(CARTON) +# f.close() +# try: +# os.chmod(carton_filename, 0755) +# except: +# # you probably don't have os.chmod +# pass + # - cleanup tempdir # shutil.rmtree(tempdir) """ @@ -214,12 +228,23 @@ # TODO: used the below hashed value of VIRTUAL_ENV if set # (set that with another file) + # get the contents of this file + carton = None + try: + if __file__: + filename = __file__.rstrip('c') # avoid pyfiles + if os.path.exists(filename): + carton = file(filename).read().encode('zlib').encode('base64') + except NameError: + pass + # interpolate "template" -> output outfile = options.outfile if outfile is None: outfile = environment + '.py' variables = {'VIRTUAL_ENV': VIRTUAL_ENV.encode('zlib').encode('base64'), 'ENV': environment, + 'CARTON': repr(carton), 'PACKAGE_SOURCES': repr(source_array)} f = file(outfile, 'w') f.write(template % variables)