[Checkins] SVN: zc.buildout/branches/dev/ Added doctest for auto part inclusion and ordering.

Jim Fulton jim at zope.com
Sun Dec 3 14:55:28 EST 2006


Log message for revision 71386:
  Added doctest for auto part inclusion and ordering.
  
  Fixed a buglet in ordering of recorded installed-part information.
  
  Removed some comments about the abandoned decision to only allow
  configured parts on the command line.  Now, when using the install
  command, you can list any parts you want.
  

Changed:
  U   zc.buildout/branches/dev/CHANGES.txt
  U   zc.buildout/branches/dev/src/zc/buildout/buildout.py
  U   zc.buildout/branches/dev/src/zc/buildout/buildout.txt

-=-
Modified: zc.buildout/branches/dev/CHANGES.txt
===================================================================
--- zc.buildout/branches/dev/CHANGES.txt	2006-12-03 14:02:02 UTC (rev 71385)
+++ zc.buildout/branches/dev/CHANGES.txt	2006-12-03 19:55:27 UTC (rev 71386)
@@ -32,8 +32,6 @@
   list before the referencing part.  This means that you can omit
   parts from the parts list if they are referenced by other parts.
 
-  XXX need tests for this.
-
 - Removed support ConfigParser-style variable substitutions
   (e.g. %(foo)s). Only the string-template style of variable
   (e.g. ${section:option}) substitutions will be supported.

Modified: zc.buildout/branches/dev/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/branches/dev/src/zc/buildout/buildout.py	2006-12-03 14:02:02 UTC (rev 71385)
+++ zc.buildout/branches/dev/src/zc/buildout/buildout.py	2006-12-03 19:55:27 UTC (rev 71386)
@@ -184,21 +184,8 @@
         conf_parts = conf_parts and conf_parts.split() or []
         installed_parts = installed_part_options['buildout']['parts']
         installed_parts = installed_parts and installed_parts.split() or []
-
-
-        # If install_parts is given, then they must be listed in parts
-        # and we don't uninstall anything. Otherwise, we install
-        # the configured parts and uninstall anything else.
-
-        # Why?
         
         if install_parts:
-##             extra = [p for p in install_parts if p not in conf_parts]
-##             if extra:
-##                 self._error(
-##                     'Invalid install parts: %s.\n'
-##                     'Install parts must be listed in the configuration.',
-##                     ' '.join(extra))
             uninstall_missing = False
         else:
             install_parts = conf_parts
@@ -311,15 +298,12 @@
                               ] = '\n'.join(installed_files)
                 saved_options['__buildout_signature__'] = signature
 
-                if part not in installed_parts:
-                    installed_parts.append(part)
+                installed_parts = [p for p in installed_parts if p != part]
+                installed_parts.append(part)
 
         finally:
-            installed_part_options['buildout']['parts'] = ' '.join(
-                [p for p in conf_parts if p in installed_parts]
-                +
-                [p for p in installed_parts if p not in conf_parts] 
-            )
+            installed_part_options['buildout']['parts'] = (
+                ' '.join(installed_parts))
             installed_part_options['buildout']['installed_develop_eggs'
                                                ] = installed_develop_eggs
             

Modified: zc.buildout/branches/dev/src/zc/buildout/buildout.txt
===================================================================
--- zc.buildout/branches/dev/src/zc/buildout/buildout.txt	2006-12-03 14:02:02 UTC (rev 71385)
+++ zc.buildout/branches/dev/src/zc/buildout/buildout.txt	2006-12-03 19:55:27 UTC (rev 71386)
@@ -532,6 +532,87 @@
 contain alphanumeric characters, hyphens, periods and spaces. This
 restriction might be relaxed in future releases.
 
+
+Automatic part selection and ordering
+-------------------------------------
+
+When a section with a recipe is refered to, either through variable
+substitution or by an initializing recipe, the section is treated as a
+part and added to the part list before the referencing part.  For
+example, we can leave data-dir out of the parts list:
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... develop = recipes
+    ... parts = debug
+    ... log-level = INFO
+    ...
+    ... [debug]
+    ... recipe = recipes:debug
+    ... File 1 = ${data-dir:path}/file
+    ... File 2 = ${debug:File 1}/log
+    ...
+    ... [data-dir]
+    ... recipe = recipes:mkdir
+    ... path = mydata
+    ... """)
+
+
+It will still be treated as a part:
+
+    >>> print system(buildout),
+    buildout: Develop: /sample-buildout/recipes/setup.py
+    buildout: Updating data-dir
+    buildout: Updating debug
+    File 1 /sample-buildout/mydata/file
+    File 2 /sample-buildout/mydata/file/log
+    recipe recipes:debug
+
+    >>> cat('.installed.cfg') # doctest: +ELLIPSIS
+    [buildout]
+    installed_develop_eggs = /sample-buildout/develop-eggs/recipes.egg-link
+    parts = data-dir debug
+    ...
+
+Note that the data-dir part is included *before* the debug part,
+because the debug part refers to the data-dir part.  Even if we list
+the data-dir part after the debug part, it will be included before:
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... develop = recipes
+    ... parts = debug data-dir
+    ... log-level = INFO
+    ...
+    ... [debug]
+    ... recipe = recipes:debug
+    ... File 1 = ${data-dir:path}/file
+    ... File 2 = ${debug:File 1}/log
+    ...
+    ... [data-dir]
+    ... recipe = recipes:mkdir
+    ... path = mydata
+    ... """)
+
+
+It will still be treated as a part:
+
+    >>> print system(buildout),
+    buildout: Develop: /sample-buildout/recipes/setup.py
+    buildout: Updating data-dir
+    buildout: Updating debug
+    File 1 /sample-buildout/mydata/file
+    File 2 /sample-buildout/mydata/file/log
+    recipe recipes:debug
+
+    >>> cat('.installed.cfg') # doctest: +ELLIPSIS
+    [buildout]
+    installed_develop_eggs = /sample-buildout/develop-eggs/recipes.egg-link
+    parts = data-dir debug
+    ...
+
 Multiple configuration files
 ----------------------------
 
@@ -926,13 +1007,19 @@
     >>> cat(sample_buildout, '.installed.cfg')
     [buildout]
     installed_develop_eggs = /sample-buildout/develop-eggs/recipes.egg-link
-    parts = debug d2 d3 d4 d1
+    parts = debug d1 d2 d3 d4
     <BLANKLINE>
     [debug]
     __buildout_installed__ = 
     __buildout_signature__ = recipes-PiIFiO8ny5yNZ1S3JfT0xg==
     recipe = recipes:debug
     <BLANKLINE>
+    [d1]
+    __buildout_installed__ = /sample-buildout/d1
+    __buildout_signature__ = recipes-PiIFiO8ny5yNZ1S3JfT0xg==
+    path = /sample-buildout/d1
+    recipe = recipes:mkdir
+    <BLANKLINE>
     [d2]
     __buildout_installed__ = /sample-buildout/d2
     __buildout_signature__ = recipes-PiIFiO8ny5yNZ1S3JfT0xg==
@@ -950,12 +1037,6 @@
     __buildout_signature__ = recipes-PiIFiO8ny5yNZ1S3JfT0xg==
     path = /sample-buildout/data4
     recipe = recipes:mkdir
-    <BLANKLINE>
-    [d1]
-    __buildout_installed__ = /sample-buildout/d1
-    __buildout_signature__ = recipes-PiIFiO8ny5yNZ1S3JfT0xg==
-    path = /sample-buildout/d1
-    recipe = recipes:mkdir
 
 Note that the installed data for debug, d1, and d2 haven't changed,
 because we didn't install those parts and that the d1 and d2
@@ -965,8 +1046,8 @@
 
     >>> print system(buildout),
     buildout: Develop: /sample-buildout/recipes/setup.py
+    buildout: Uninstalling d2
     buildout: Uninstalling d1
-    buildout: Uninstalling d2
     buildout: Uninstalling debug
     buildout: Installing debug
     recipe recipes:debug



More information about the Checkins mailing list