[Checkins] SVN: zc.recipe.cmmi/trunk/ merge in changes to support patch downloading. bump version number as this is a feature#

Miles Waller miles at jamkit.com
Sat Sep 8 13:08:58 EDT 2007


Log message for revision 79530:
  merge in changes to support patch downloading.  bump version number as this is a feature#

Changed:
  U   zc.recipe.cmmi/trunk/CHANGES.txt
  U   zc.recipe.cmmi/trunk/setup.py
  U   zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py
  A   zc.recipe.cmmi/trunk/zc/recipe/cmmi/patching.txt
  U   zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py

-=-
Modified: zc.recipe.cmmi/trunk/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt	2007-09-08 12:21:13 UTC (rev 79529)
+++ zc.recipe.cmmi/trunk/CHANGES.txt	2007-09-08 17:08:57 UTC (rev 79530)
@@ -1,6 +1,12 @@
 Release History
 ***************
 
+After 1.1.0
+===========
+
+Added support for patches to be downloaded from a url rather than only using
+patches on the filesystem
+
 1.1.0
 =====
 

Modified: zc.recipe.cmmi/trunk/setup.py
===================================================================
--- zc.recipe.cmmi/trunk/setup.py	2007-09-08 12:21:13 UTC (rev 79529)
+++ zc.recipe.cmmi/trunk/setup.py	2007-09-08 17:08:57 UTC (rev 79530)
@@ -21,7 +21,7 @@
 name = "zc.recipe.cmmi"
 setup(
     name = name,
-    version = "1.1.1",
+    version = "1.2.1",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "ZC Buildout recipe for configure/make/make install",

Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py	2007-09-08 12:21:13 UTC (rev 79529)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py	2007-09-08 17:08:57 UTC (rev 79530)
@@ -71,7 +71,7 @@
         os.mkdir(dest)
 
         try:
-            os.chdir(tmp)                                        
+            os.chdir(tmp)
             try:
                 if not os.path.exists('configure'):
                     entries = os.listdir(tmp)
@@ -80,6 +80,14 @@
                     else:
                         raise ValueError("Couldn't find configure")
                 if patch is not '':
+                    # patch may be a filesystem path or url
+                    # url patches can go through the cache
+                    if urlparse.urlparse( patch, None)[0] is not None:
+                        patch = getFromCache( patch
+                                            , self.name
+                                            , self.download_cache
+                                            , self.install_from_cache
+                                            )
                     system("patch %s < %s" % (patch_options, patch))
                 system("./configure --prefix=%s %s" %
                        (dest, extra_options))

Copied: zc.recipe.cmmi/trunk/zc/recipe/cmmi/patching.txt (from rev 79529, zc.recipe.cmmi/branches/miwa-patch-url/zc/recipe/cmmi/patching.txt)
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/patching.txt	                        (rev 0)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/patching.txt	2007-09-08 17:08:57 UTC (rev 79530)
@@ -0,0 +1,86 @@
+Loading Patces from URLs
+========================
+
+Patch files can be loaded from URLs as well as files.
+
+Any downloaded patch files can be cached in a download cache if 
+available, in exactly the same way as for tarballs.  Similarly, 
+if the build is set to offline operation, then it will not download 
+from a remote location.
+
+To see how this works, we'll set up a web server with a patch file, 
+and a cache with our tarball in:
+
+    >>> import sys, os
+    >>> cache = tmpdir('cache')
+    >>> patch_data = tmpdir('patch_data')
+    >>> patchfile = os.path.join(patch_data, 'config.patch')
+    >>> write(patchfile,
+    ... """--- configure
+    ... +++ /dev/null
+    ... @@ -1,13 +1,13 @@
+    ...  #!%s
+    ...  import sys
+    ... -print "configuring foo", ' '.join(sys.argv[1:])
+    ... +print "configuring foo patched", ' '.join(sys.argv[1:])
+    ...
+    ...  Makefile_template = '''
+    ...  all:
+    ... -\techo building foo
+    ... +\techo building foo patched
+    ...
+    ...  install:
+    ... -\techo installing foo
+    ... +\techo installing foo patched
+    ...  '''
+    ...
+    ...  open('Makefile', 'w').write(Makefile_template)
+    ...
+    ... """ % sys.executable)
+
+    >>> server_url = start_server(patch_data)
+
+Now let's create a buildout.cfg file.
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ... download-cache=%(cache)s
+    ... log-level = DEBUG
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = file://%(distros)s/foo.tgz
+    ... patch = %(server_url)s/config.patch
+    ... """ % dict(distros=distros,server_url=server_url,cache=cache))
+
+    >>> print system('bin/buildout'),
+    In...
+    Installing foo.
+    foo: Searching cache at /cache/cmmi
+    foo: Did not find foo.tgz under cache key /cache/cmmi/...
+    foo: Cache download /distros/foo.tgz as /cache/cmmi/...
+    foo: Unpacking and configuring
+    foo: Searching cache at /cache/cmmi
+    foo: Did not find config.patch under cache key /cache/cmmi/...
+    foo: Cache download .../config.patch as /cache/cmmi/...
+    patching file configure
+    configuring foo patched /sample-buildout/parts/foo
+    echo building foo patched
+    building foo patched
+    echo installing foo patched
+    installing foo patched
+
+Any downloaded patch files can be cached in a download cache if available, in
+exactly the same way as for tarballs.  Similarly, if the build is set to offline
+operation, then it will not download from a remote location.
+
+We can see that the patch is now in the cache, as well as the tarball:
+
+    >>> import os
+    >>> cache_path = os.path.join(cache, 'cmmi')
+    >>> ls(cache_path)
+    d ...
+    d ...
+

Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py	2007-09-08 12:21:13 UTC (rev 79529)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py	2007-09-08 17:08:57 UTC (rev 79530)
@@ -72,6 +72,21 @@
             ),
         
         doctest.DocFileSuite(
+            'patching.txt',
+            setUp=setUp,
+            tearDown=zc.buildout.testing.buildoutTearDown,
+
+            checker=renormalizing.RENormalizing([
+               zc.buildout.testing.normalize_path,
+               zc.buildout.testing.normalize_script,
+               zc.buildout.testing.normalize_egg_py,
+               normalize_bang,
+               (re.compile('extdemo[.]pyd'), 'extdemo.so')
+               ]),
+            optionflags = doctest.ELLIPSIS
+            ),
+
+        doctest.DocFileSuite(
             'downloadcache.txt',
             setUp=setUp,
             tearDown=zc.buildout.testing.buildoutTearDown,
@@ -85,4 +100,5 @@
                ]),
             optionflags = doctest.ELLIPSIS
             ),
+
         ))



More information about the Checkins mailing list