Description: Cleanup temporary directory created with mkdtemp()
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: https://github.com/pypa/virtualenv/pull/231
Bug-Debian: http://bugs.debian.org/661272
Date:   Sat Feb 25 22:07:41 2012 +0200

--- a/virtualenv.py
+++ b/virtualenv.py
@@ -568,6 +568,8 @@
     finally:
         logger.indent -= 2
         logger.end_progress()
+        if cwd is not None:
+            shutil.rmtree(cwd)
         if os.getcwd() != old_chdir:
             os.chdir(old_chdir)
         if is_jython and os._name == 'nt':
--- a/virtualenv_embedded/distribute_setup.py
+++ b/virtualenv_embedded/distribute_setup.py
@@ -14,6 +14,7 @@
 This file can also be run as a script to install or upgrade setuptools.
 """
 import os
+import shutil
 import sys
 import time
 import fnmatch
@@ -86,6 +87,7 @@
             log.warn('See the error message above.')
     finally:
         os.chdir(old_wd)
+        shutil.rmtree(tmpdir)
 
 
 def _build_egg(egg, tarball, to_dir):
@@ -110,6 +112,7 @@
 
     finally:
         os.chdir(old_wd)
+        shutil.rmtree(tmpdir)
     # returning the result
     log.warn(egg)
     if not os.path.exists(egg):
