changeset 27:dace84448c25

carry carton along with carton
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 10 Jul 2011 18:48:30 -0700
parents e6ee0410ceef
children dabf5e1bdf92
files carton.py tests/doctest.txt
diffstat 2 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/carton.py	Sun Jul 10 18:37:42 2011 -0700
+++ b/carton.py	Sun Jul 10 18:48:30 2011 -0700
@@ -123,22 +123,21 @@
 if os.path.exists(os.path.join(virtualenv_dir, 'setup.py')):
     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
+# 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
+# TODO: cleanup tempdir
 # shutil.rmtree(tempdir)
 """
 
--- a/tests/doctest.txt	Sun Jul 10 18:37:42 2011 -0700
+++ b/tests/doctest.txt	Sun Jul 10 18:48:30 2011 -0700
@@ -44,6 +44,17 @@
     >>> os.path.exists(os.path.join(bin, 'virtualenv')) or os.path.exists(os.path.join(bin, 'virtualenv.exe'))
     True
 
+Ensure you're bringing along carton::
+
+    >>> packaged_carton = os.path.join(bin, 'carton.py')
+    >>> os.path.exists(packaged_carton)
+    True
+    >>> carton_module = carton.__file__.rstrip('c')
+    >>> os.path.exists(carton_module)
+    True
+    >>> file(packaged_carton).read() == file(carton_module).read()
+    True
+    
 Show that non-package files get carried along too::
 
     >>> os.path.exists(os.path.join('foo', 'src', 'packageA', 'foo.txt'))