Commit 5f786b1f authored by jim's avatar jim

- 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.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@75701 62d5b8a3-27da-0310-9561-8e5933582275
parent 0175e358
...@@ -11,6 +11,20 @@ priorities include: ...@@ -11,6 +11,20 @@ priorities include:
Change History 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) 1.0.0b24 (2007-05-09)
===================== =====================
......
...@@ -35,7 +35,7 @@ open('doc.txt', 'w').write(long_description) ...@@ -35,7 +35,7 @@ open('doc.txt', 'w').write(long_description)
name = "zc.buildout" name = "zc.buildout"
setup( setup(
name = name, name = name,
version = "1.0.0b24", version = "1.0.0b25",
author = "Jim Fulton", author = "Jim Fulton",
author_email = "jim@zope.com", author_email = "jim@zope.com",
description = "System for managing development buildouts", description = "System for managing development buildouts",
......
...@@ -172,6 +172,8 @@ class Buildout(UserDict.DictMixin): ...@@ -172,6 +172,8 @@ class Buildout(UserDict.DictMixin):
for name in _buildout_default_options: for name in _buildout_default_options:
options[name] options[name]
os.chdir(options['directory'])
def _buildout_path(self, *names): def _buildout_path(self, *names):
return os.path.join(self._buildout_dir, *names) return os.path.join(self._buildout_dir, *names)
...@@ -923,9 +925,11 @@ class Options(UserDict.DictMixin): ...@@ -923,9 +925,11 @@ class Options(UserDict.DictMixin):
return result return result
def _call(self, f): def _call(self, f):
buildout_directory = self.buildout['buildout']['directory']
self._created = [] self._created = []
try: try:
try: try:
os.chdir(buildout_directory)
return f() return f()
except: except:
for p in self._created: for p in self._created:
...@@ -938,6 +942,7 @@ class Options(UserDict.DictMixin): ...@@ -938,6 +942,7 @@ class Options(UserDict.DictMixin):
raise raise
finally: finally:
self._created = None self._created = None
os.chdir(buildout_directory)
def created(self, *paths): def created(self, *paths):
try: try:
......
...@@ -584,6 +584,7 @@ if os.path.exists(bootstrap_py): ...@@ -584,6 +584,7 @@ if os.path.exists(bootstrap_py):
buildout: Creating directory ...parts buildout: Creating directory ...parts
buildout: Creating directory ...eggs buildout: Creating directory ...eggs
buildout: Creating directory ...develop-eggs buildout: Creating directory ...develop-eggs
zc.buildout.easy_install: Generated script /sample/bin/buildout.
>>> ls(sample_buildout) >>> ls(sample_buildout)
d bin d bin
...@@ -1984,6 +1985,57 @@ if sys.version_info > (2, 4): ...@@ -1984,6 +1985,57 @@ if sys.version_info > (2, 4):
""" """
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
"""
###################################################################### ######################################################################
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment