Commit c567bb2d authored by Xavier Thompson's avatar Xavier Thompson

[feat] Warn when bootstrap finds dists in site-packages

And avoid creating a .egg-link pointing to site-packages.
parent 425a1f60
...@@ -762,10 +762,15 @@ class Buildout(DictMixin): ...@@ -762,10 +762,15 @@ 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.
# XXX Note: except if the current modules are not eggs, in which case # XXX Note: except if the current modules are not eggs. In particular,
# we'll create .egg-link to them. This applies to packages installed # this concerns .dist-info packages installed by pip in site-packages
# in site-packages by pip (.dist-info, not .egg), which in turn would # or elsewhere: setuptools does not distinguish dists installed by pip
# cause site-packages to be in the sys.path of the generated script. # 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']
...@@ -786,11 +791,25 @@ class Buildout(DictMixin): ...@@ -786,11 +791,25 @@ class Buildout(DictMixin):
link_dists = [] 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'], if dist.location == zc.buildout.easy_install.python_lib:
dist.key + '.egg-link') # Special-case exception for site-packages
with open(dest, 'w') as fh: self._logger.warning(
fh.write(dist.location) "Distribution %s was found in sites-packages (%s). "
link_dists.append(dist) "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")
# 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.
else:
dest = os.path.join(
self['buildout']['develop-eggs-directory'],
dist.key + '.egg-link')
with open(dest, 'w') as fh:
fh.write(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))
......
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