[Checkins] SVN: zc.buildout/trunk/src/zc/buildout/buildout.py
Refactored to harder to make sure that buildout directory
options are
Jim Fulton
jim at zope.com
Fri Jul 18 16:38:29 EDT 2008
Log message for revision 88545:
Refactored to harder to make sure that buildout directory options are
absolute before parts read them. This fix was motivated by a test
provoked reading the options before they were absoluticated.
Added a special check for trying to remove buildout.exe, which fails
on windows and is generally pointless. :)
Changed:
U zc.buildout/trunk/src/zc/buildout/buildout.py
-=-
Modified: zc.buildout/trunk/src/zc/buildout/buildout.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/buildout.py 2008-07-18 20:34:32 UTC (rev 88544)
+++ zc.buildout/trunk/src/zc/buildout/buildout.py 2008-07-18 20:38:29 UTC (rev 88545)
@@ -77,6 +77,7 @@
# default options
data = dict(buildout=_buildout_default_options.copy())
+ self._buildout_dir = os.getcwd()
if not _isurl(config_file):
config_file = os.path.abspath(config_file)
@@ -125,7 +126,16 @@
# provide some defaults before options are parsed
# because while parsing options those attributes might be
# used already (Gottfried Ganssauge)
- buildout_section = data.get ('buildout')
+ buildout_section = data.get('buildout')
+
+ # Try to make sure we have absolute paths for standard directories. We do this
+ # before doing substitutions, in case a one of these gets read by another section.
+ if 'directory' in buildout_section:
+ self._buildout_dir = buildout_section['directory']
+ for name in ('bin', 'parts', 'eggs', 'develop-eggs'):
+ d = self._buildout_path(buildout_section[name+'-directory'])
+ buildout_section[name+'-directory'] = d
+
links = buildout_section and buildout_section.get('find-links', '')
self._links = links and links.split() or ()
@@ -134,7 +144,6 @@
self._allow_hosts = tuple([host.strip() for host in allow_hosts
if host.strip() != ''])
- self._buildout_dir = os.getcwd()
self._logger = logging.getLogger('zc.buildout')
self.offline = False
self.newest = True
@@ -156,6 +165,9 @@
if host.strip() != ''])
self._buildout_dir = options['directory']
+
+ # Make sure we have absolute paths for standard directories. We do this
+ # a second time here in case someone overrode these in their configs.
for name in ('bin', 'parts', 'eggs', 'develop-eggs'):
d = self._buildout_path(options[name+'-directory'])
options[name+'-directory'] = d
@@ -600,7 +612,20 @@
if os.path.isdir(f):
rmtree(f)
elif os.path.isfile(f):
- os.remove(f)
+ try:
+ os.remove(f)
+ except OSError:
+ if not (
+ sys.platform == 'win32' and
+ (realpath(os.path.join(os.path.dirname(sys.argv[0]),
+ 'buildout.exe'))
+ ==
+ realpath(f)
+ )
+ # Sigh. This is the exectable used to run the buildout
+ # and, of course, it's in use. Leave it.
+ ):
+ raise
def _install(self, part):
options = self[part]
More information about the Checkins
mailing list