changeset 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
files carton.py
diffstat 1 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)