[Checkins] SVN: zc.buildout/trunk/ - buildout changes to the buildout directory before running recipe

Jim Fulton jim at zope.com
Sat May 12 09:50:18 EDT 2007


Log message for revision 75701:
  - buildout changes to the buildout directory before running recipe
    install and update methods.
  
  - 59270: Buggy recipes can cause failures in later recipes via chdir
  
  Also updated a test to reflect logging of script installation.
  

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/setup.py
  U   zc.buildout/trunk/src/zc/buildout/buildout.py
  U   zc.buildout/trunk/src/zc/buildout/tests.py

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2007-05-12 13:00:03 UTC (rev 75700)
+++ zc.buildout/trunk/CHANGES.txt	2007-05-12 13:50:18 UTC (rev 75701)
@@ -11,6 +11,20 @@
 Change History
 **************
 
+1.0.0b25 (2007-05-??)
+=====================
+
+Feature Changes
+---------------
+
+- buildout changes to the buildout directory before running recipe
+  install and update methods.
+
+Bugs Fixed
+----------
+
+- 59270: Buggy recipes can cause failures in later recipes via chdir
+
 1.0.0b24 (2007-05-09)
 =====================
 

Modified: zc.buildout/trunk/setup.py
===================================================================
--- zc.buildout/trunk/setup.py	2007-05-12 13:00:03 UTC (rev 75700)
+++ zc.buildout/trunk/setup.py	2007-05-12 13:50:18 UTC (rev 75701)
@@ -35,7 +35,7 @@
 name = "zc.buildout"
 setup(
     name = name,
-    version = "1.0.0b24",
+    version = "1.0.0b25",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "System for managing development buildouts",

Modified: zc.buildout/trunk/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.py	2007-05-12 13:00:03 UTC (rev 75700)
+++ zc.buildout/trunk/src/zc/buildout/buildout.py	2007-05-12 13:50:18 UTC (rev 75701)
@@ -172,6 +172,8 @@
         for name in _buildout_default_options:
             options[name]
 
+        os.chdir(options['directory'])
+
     def _buildout_path(self, *names):
         return os.path.join(self._buildout_dir, *names)
 
@@ -923,9 +925,11 @@
         return result
 
     def _call(self, f):
+        buildout_directory = self.buildout['buildout']['directory']
         self._created = []
         try:
             try:
+                os.chdir(buildout_directory)
                 return f()
             except:
                 for p in self._created:
@@ -938,6 +942,7 @@
                 raise
         finally:
             self._created = None
+            os.chdir(buildout_directory)
 
     def created(self, *paths):
         try:

Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py	2007-05-12 13:00:03 UTC (rev 75700)
+++ zc.buildout/trunk/src/zc/buildout/tests.py	2007-05-12 13:50:18 UTC (rev 75701)
@@ -584,6 +584,7 @@
     buildout: Creating directory ...parts
     buildout: Creating directory ...eggs
     buildout: Creating directory ...develop-eggs
+    zc.buildout.easy_install: Generated script /sample/bin/buildout.
 
     >>> ls(sample_buildout)
     d  bin
@@ -1984,7 +1985,58 @@
 
         """
 
+def bug_59270_recipes_always_start_in_buildout_dir():
+    """
+    Recipes can rely on running from buildout directory
 
+    >>> mkdir('bad_start')
+    >>> write('bad_recipe.py',
+    ... '''
+    ... import os
+    ... class Bad:
+    ...     def __init__(self, *_):
+    ...         print os.getcwd()
+    ...     def install(self):
+    ...         print os.getcwd()
+    ...         os.chdir('bad_start')
+    ...         print os.getcwd()
+    ...         return ()
+    ... ''')
+
+    >>> write('setup.py',
+    ... '''
+    ... from setuptools import setup
+    ... setup(name='bad.test',
+    ...       entry_points={'zc.buildout': ['default=bad_recipe:Bad']},)
+    ... ''')
+    
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... develop = .
+    ... parts = b1 b2
+    ... [b1]
+    ... recipe = bad.test
+    ... [b2]
+    ... recipe = bad.test
+    ... ''')
+
+    >>> os.chdir('bad_start')
+    >>> print system(join(sample_buildout, 'bin', 'buildout')
+    ...              +' -c '+join(sample_buildout, 'buildout.cfg')),
+    buildout: Develop: /tmp/tmpV9ptXUbuildoutSetUp/_TEST_/sample-buildout/.
+    /sample-buildout
+    /sample-buildout
+    buildout: Installing b1
+    /sample-buildout
+    /sample-buildout/bad_start
+    buildout: Installing b2
+    /sample-buildout
+    /sample-buildout/bad_start
+    
+    """
+
+
 ######################################################################
     
 def create_sample_eggs(test, executable=sys.executable):



More information about the Checkins mailing list