Commit e67e8a57 authored by Xavier Thompson's avatar Xavier Thompson

[wkrd] Warn when bootstrap finds .{dist|egg}-info

And avoid creating a .egg-link pointing to their location.
parent b2607926
...@@ -764,13 +764,7 @@ class Buildout(DictMixin): ...@@ -764,13 +764,7 @@ class Buildout(DictMixin):
# XXX Note: except if the current modules are not eggs. In particular, # XXX Note: except if the current modules are not eggs. In particular,
# this concerns .dist-info packages installed by pip in site-packages # this concerns .dist-info packages installed by pip in site-packages
# or elsewhere: setuptools does not distinguish dists installed by pip # or elsewhere.
# from actual develop dists. This may lead to the creation of .egg-link
# files in ./develop-eggs linking to the original location.
# A special-case exception is made when the location is site-packages
# to avoid putting links to site-packages in ./develop-eggs. This is
# merely a mitigation and does not preclude other shared locations
# being linked in ./develop-eggs.
# Sort the working set to keep entries with single dists first. # Sort the working set to keep entries with single dists first.
options = self['buildout'] options = self['buildout']
...@@ -787,6 +781,9 @@ class Buildout(DictMixin): ...@@ -787,6 +781,9 @@ class Buildout(DictMixin):
# Now copy buildout and setuptools eggs, and record destination eggs. # Now copy buildout and setuptools eggs, and record destination eggs.
# XXX Note: dists using .dist-info format - e.g. packages installed by # 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. # pip in site-packages - will be seen as develop dists and not copied.
# Instead of linking them in ./develop-eggs like actual develop dists,
# a warning is emitted to avoid linking a directory that can contain
# multiple dists, with unintended and unexpected results later.
egg_entries = [] egg_entries = []
develop_dists = [] develop_dists = []
for dist in ws: for dist in ws:
...@@ -800,12 +797,19 @@ class Buildout(DictMixin): ...@@ -800,12 +797,19 @@ class Buildout(DictMixin):
"Consider using 'buildout:extra-paths=' to install it " "Consider using 'buildout:extra-paths=' to install it "
"from scratch in isolation directly in eggs-directory." "from scratch in isolation directly in eggs-directory."
% (dist, dist.location)) % (dist, dist.location))
# XXX: TODO: Ideally we should be able to distinguish
# .dist-info dists from develop dists, and support bundling
# .dist-info packages into individual '.dist' bundles that
# could be put in ./eggs, with support in buildout for
# using such distribution.
continue continue
elif zc.buildout.easy_install.is_externally_managed_dist(dist):
# Exception for .dist-info and .egg-info
self._logger.warning(
"Distribution %s (%s) is a .dist-info or a .egg-info. "
"Avoiding creating a link in develop-eggs-directory.\n"
"Consider using 'buildout:extra-paths=' to install it "
"from scratch in isolation directly in eggs-directory."
% (dist, dist.location))
continue
# XXX: Maybe support bundling <project>.dist-info and <project>
# into a containing <project>.dist directory and copying it in
# ./eggs when the dist found is a .dist-info.
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:
......
...@@ -1910,6 +1910,16 @@ UNPACKERS = { ...@@ -1910,6 +1910,16 @@ UNPACKERS = {
} }
def is_dist_info(dist):
return isinstance(dist, pkg_resources.DistInfoDistribution)
def is_egg_info(dist):
return isinstance(dist, pkg_resources.EggInfoDistribution)
def is_externally_managed_dist(dist):
return is_dist_info(dist) or is_egg_info(dist)
def _get_matching_dist_in_location(dist, location): def _get_matching_dist_in_location(dist, location):
""" """
Check if `locations` contain only the one intended dist. Check if `locations` contain only the one intended dist.
......
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