Commit 5834ec9e authored by Xavier Thompson's avatar Xavier Thompson

[fix] Fix bootstrap working set order

In bootstrap we potentially copy eggs from the working set to ./eggs.
We then reconstruct the same working set using the moved locations.

This commits ensures we keep a correct working set order throughout
and that we avoid activating unintended dists.
parent f8a65f4f
...@@ -717,38 +717,56 @@ class Buildout(DictMixin): ...@@ -717,38 +717,56 @@ class Buildout(DictMixin):
# nothing will be installed, but then we'll copy them to # nothing will be installed, but then we'll copy them to
# the local eggs or develop-eggs folder just after this. # the local eggs or develop-eggs folder just after this.
# Now copy buildout and setuptools eggs, and record destination eggs: # XXX Note: except if the current modules are not eggs, in which case
entries = [] # we'll create .egg-link to them. This applies to packages installed
# in site-packages by pip (.dist-info, not .egg), which in turn would
# cause site-packages to be in the sys.path of the generated script.
# Sort the working set to keep entries with single dists first.
options = self['buildout']
buildout_dir = options['directory']
eggs_dir = options['eggs-directory']
develop_eggs_dir = options['develop-eggs-directory']
ws = zc.buildout.easy_install.sort_working_set(
ws,
buildout_dir=buildout_dir,
eggs_dir=eggs_dir,
develop_eggs_dir=develop_eggs_dir
)
# Now copy buildout and setuptools eggs, and record destination eggs.
# XXX Note: dists using .dist-info format - e.g. packages installed by
# pip in site-packages - will be seen as develop dists and not copied.
egg_entries = []
link_dists = []
for dist in ws: for dist in ws:
if dist.precedence == pkg_resources.DEVELOP_DIST: if dist.precedence == pkg_resources.DEVELOP_DIST:
dest = os.path.join(self['buildout']['develop-eggs-directory'], dest = os.path.join(self['buildout']['develop-eggs-directory'],
dist.key + '.egg-link') dist.key + '.egg-link')
with open(dest, 'w') as fh: with open(dest, 'w') as fh:
fh.write(dist.location) fh.write(dist.location)
entries.append(dist.location) link_dists.append(dist)
else: else:
dest = os.path.join(self['buildout']['eggs-directory'], dest = os.path.join(self['buildout']['eggs-directory'],
os.path.basename(dist.location)) os.path.basename(dist.location))
entries.append(dest) egg_entries.append(dest)
if not os.path.exists(dest): if not os.path.exists(dest):
if os.path.isdir(dist.location): if os.path.isdir(dist.location):
shutil.copytree(dist.location, dest) shutil.copytree(dist.location, dest)
else: else:
shutil.copy2(dist.location, dest) shutil.copy2(dist.location, dest)
# Create buildout script # Recreate a working set with the potentially-new paths after copying.
ws = pkg_resources.WorkingSet(entries) # We keep the eggs dists first since we know their locations contain a
# single dist. We add the other dists manually to avoid activating any
# unneded dists at the same location, and we can because these are the
# same dists as before as they were not copied.
ws = pkg_resources.WorkingSet(egg_entries)
for dist in link_dists:
ws.add(dist)
ws.require('zc.buildout') ws.require('zc.buildout')
options = self['buildout']
buildout_dir = options['directory'] # Create buildout script
eggs_dir = options['eggs-directory']
develop_eggs_dir = options['develop-eggs-directory']
ws = zc.buildout.easy_install.sort_working_set(
ws,
buildout_dir=buildout_dir,
eggs_dir=eggs_dir,
develop_eggs_dir=develop_eggs_dir
)
zc.buildout.easy_install.scripts( zc.buildout.easy_install.scripts(
['zc.buildout'], ws, sys.executable, ['zc.buildout'], ws, sys.executable,
options['bin-directory'], options['bin-directory'],
......
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