[Checkins] SVN: zc.recipe.cmmi/branches/1.2/ Backport fixes from 1.3.3

Patrick Strawderman patrick at zope.com
Wed Nov 10 18:18:41 EST 2010


Log message for revision 118330:
  Backport fixes from 1.3.3
  

Changed:
  U   zc.recipe.cmmi/branches/1.2/CHANGES.txt
  U   zc.recipe.cmmi/branches/1.2/buildout.cfg
  U   zc.recipe.cmmi/branches/1.2/setup.py
  U   zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/README.txt
  U   zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/__init__.py
  U   zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/shared.txt
  U   zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/tests.py

-=-
Modified: zc.recipe.cmmi/branches/1.2/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/branches/1.2/CHANGES.txt	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/CHANGES.txt	2010-11-10 23:18:40 UTC (rev 118330)
@@ -1,12 +1,20 @@
 Release History
 ***************
 
-1.2.2 (unreleased)
+1.2.2 (2010-11-10)
 ==================
 
-- Nothing changed yet.
+- Declare a test dependency on zope.testing.
 
+- Clean up temporary download files.
 
+The following changes were backported from 1.3.3:
+
+- Remove the temporary build directory when cmmi succeeds.
+
+- Specify that the zc.buildout version be <1.5.0b1.
+
+
 1.2.1 (2009-08-12)
 ==================
 

Modified: zc.recipe.cmmi/branches/1.2/buildout.cfg
===================================================================
--- zc.recipe.cmmi/branches/1.2/buildout.cfg	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/buildout.cfg	2010-11-10 23:18:40 UTC (rev 118330)
@@ -4,5 +4,5 @@
 
 [test]
 recipe = zc.recipe.testrunner
-eggs = zc.recipe.cmmi
+eggs = zc.recipe.cmmi [test]
 

Modified: zc.recipe.cmmi/branches/1.2/setup.py
===================================================================
--- zc.recipe.cmmi/branches/1.2/setup.py	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/setup.py	2010-11-10 23:18:40 UTC (rev 118330)
@@ -53,7 +53,8 @@
     include_package_data = True,
     data_files = [('.', ['README.txt'])],
     namespace_packages = ['zc', 'zc.recipe'],
-    install_requires = ['zc.buildout', 'setuptools'],
+    install_requires = ['zc.buildout <1.5.0b1', 'setuptools'],
+    extras_require = dict(test=['zope.testing']),
     entry_points = {'zc.buildout':
                     ['default = %s:Recipe' % name]},
     zip_safe = True,

Modified: zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/README.txt
===================================================================
--- zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/README.txt	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/README.txt	2010-11-10 23:18:40 UTC (rev 118330)
@@ -191,3 +191,78 @@
     building foo
     echo installing foo
     installing foo
+
+If the build fails, the temporary directory where the tarball was unpacked
+is logged to stdout, and left intact for debugging purposes.
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = file://%s/foo.tgz
+    ... patch = ${buildout:directory}/patches/config.patch
+    ... """ % distros)
+
+    >>> write('patches/config.patch', "dgdgdfgdfg")
+
+    >>> res =  system('bin/buildout')
+    >>> print res
+    Uninstalling foo.
+    Installing foo.
+    foo: Downloading .../foo.tgz
+    foo: Unpacking and configuring
+    patch unexpectedly ends in middle of line
+    foo: cmmi failed: /.../...buildout-foo
+    patch: **** Only garbage was found in the patch input.
+    While:
+      Installing foo.
+    <BLANKLINE>
+    An internal error occured due to a bug in either zc.buildout or in a
+    recipe being used:
+    ...
+    SystemError: ('Failed', 'patch -p0 < /.../patches/config.patch')
+    <BLANKLINE>
+
+    >>> import re
+    >>> import os.path
+    >>> import shutil
+    >>> path = re.search('foo: cmmi failed: (.*)', res).group(1)
+    >>> os.path.exists(path)
+    True
+    >>> shutil.rmtree(path)
+
+After a successful build, such temporary directories are removed.
+
+    >>> import glob
+    >>> import tempfile
+
+    >>> tempdir = tempfile.gettempdir()
+    >>> dirs = glob.glob(os.path.join(tempdir, '*buildout-foo'))
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = file://%s/foo.tgz
+    ... """ % distros)
+
+    >>> print system("bin/buildout")
+    Installing foo.
+    foo: Downloading .../foo.tgz
+    foo: Unpacking and configuring
+    configuring foo --prefix=/sample_buildout/parts/foo
+    echo building foo
+    building foo
+    echo installing foo
+    installing foo
+    <BLANKLINE>
+
+    >>> new_dirs = glob.glob(os.path.join(tempdir, '*buildout-foo'))
+    >>> dirs == new_dirs
+    True

Modified: zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/__init__.py	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/__init__.py	2010-11-10 23:18:40 UTC (rev 118330)
@@ -109,13 +109,17 @@
         if not os.path.exists(dest):
             os.mkdir(dest)
 
-        fname = getFromCache(
+        fname, is_temp = getFromCache(
             self.url, self.name, self.download_cache, self.install_from_cache)
 
-        # now unpack and work as normal
-        tmp = tempfile.mkdtemp('buildout-'+self.name)
-        logger.info('Unpacking and configuring')
-        setuptools.archive_util.unpack_archive(fname, tmp)
+        try:
+            # now unpack and work as normal
+            tmp = tempfile.mkdtemp('buildout-'+self.name)
+            logger.info('Unpacking and configuring')
+            setuptools.archive_util.unpack_archive(fname, tmp)
+        finally:
+            if is_temp:
+                os.remove(fname)
 
         for key, value in self.environ.items():
             logger.info('Updating environment: %s=%s' % (key, value))
@@ -133,12 +137,15 @@
                     # patch may be a filesystem path or url
                     # url patches can go through the cache
                     if urlparse.urlparse(self.patch, None)[0] is not None:
-                        self.patch = getFromCache( self.patch
-                                            , self.name
-                                            , self.download_cache
-                                            , self.install_from_cache
-                                            )
-                    system("patch %s < %s" % (self.patch_options, self.patch))
+                        self.patch, is_temp = getFromCache(
+                            self.patch, self.name, self.download_cache,
+                            self.install_from_cache)
+                    try:
+                        system(
+                            "patch %s < %s" % (self.patch_options, self.patch))
+                    finally:
+                        if is_temp:
+                            os.remove(self.patch)
                 if self.autogen is not '':
                     logger.info('auto generating configure files')
                     system("./%s" % self.autogen)
@@ -152,9 +159,12 @@
                        (dest, self.extra_options))
                 system("make")
                 system("make install")
+                shutil.rmtree(tmp)
             finally:
                 os.chdir(here)
         except:
+            if os.path.exists(tmp):
+                logger.error("cmmi failed: %s", tmp)
             shutil.rmtree(dest)
             raise
 
@@ -214,15 +224,16 @@
                     'Cache download %s as %s' % (url, cache_name))
             else:
                 # use tempfile
-                tmp2 = tempfile.mkdtemp('buildout-' + name)
-                fname = os.path.join(tmp2, filename)
+                fd, tmp2 = tempfile.mkstemp('buildout-' + name)
+                os.close(fd)
+                fname = tmp2
                 logging.getLogger(name).info('Downloading %s' % url)
             open(fname, 'wb').write(urllib2.urlopen(url).read())
         except:
             if tmp2 is not None:
-               shutil.rmtree(tmp2)
+               os.remove(tmp2)
             if download_cache:
                shutil.rmtree(cache_name)
             raise
 
-    return fname
+    return fname, bool(tmp2)

Modified: zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/shared.txt
===================================================================
--- zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/shared.txt	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/shared.txt	2010-11-10 23:18:40 UTC (rev 118330)
@@ -183,11 +183,18 @@
     ... """ % (cache, distros))
 
     >>> remove('.installed.cfg')
-    >>> print system('bin/buildout')
+    >>> res = system('bin/buildout')
+    >>> print res
     Installing foo.
     ...
     ValueError: Couldn't find configure
 
+The temporary directory where tarball was unpacked was left behind for
+debugging purposes.
+
+    >>> import re
+    >>> shutil.rmtree(re.search('foo: cmmi failed: (.*)', res).group(1))
+
 When we now fix the error (by copying back the working version and resetting the
 cache), the build will be run again, and we don't use a half-baked shared
 directory:

Modified: zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/tests.py
===================================================================
--- zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/tests.py	2010-11-10 23:09:23 UTC (rev 118329)
+++ zc.recipe.cmmi/branches/1.2/src/zc/recipe/cmmi/tests.py	2010-11-10 23:18:40 UTC (rev 118330)
@@ -17,7 +17,6 @@
 
 import unittest
 import doctest
-import zope.testing
 from zope.testing import renormalizing
 from zc.buildout.tests import easy_install_SetUp
 from zc.buildout.tests import normalize_bang



More information about the checkins mailing list