Commit 281dc5d1 authored by Xavier Thompson's avatar Xavier Thompson

[fix] Sign develop eggs with directory hash

Mark .dist-info eggs installed by buildout as develop to distinguish
them from .dist-info eggs from the system and decide how to sign the
egg accordingly (with directory hash or with version).
parent 06ee62e8
......@@ -2322,6 +2322,25 @@ def _dir_hash(dir):
_dir_hashes[dir] = dir_hash = hash.hexdigest()
return dir_hash
def _is_develop(dist):
# Best effort guess on whether a dist was installed as develop dist
if dist.precedence != pkg_resources.DEVELOP_DIST:
return False
elif dist.location == zc.buildout.easy_install.python_lib:
return False
elif isinstance(dist, pkg_resources.EggInfoDistribution):
return True
elif isinstance(dist, pkg_resources.DistInfoDistribution):
dist_info = dist.egg_info
try:
with open(os.path.join(dist_info, 'INSTALLER')) as f:
return zc.buildout.easy_install.DEVELOP_INSTALLER in f.read()
except IOError as e:
if e.errno != errno.ENOENT:
raise
return False
return True
def _dists_sig(dists):
seen = set()
result = []
......@@ -2329,11 +2348,8 @@ def _dists_sig(dists):
if dist in seen:
continue
seen.add(dist)
location = dist.location
if (dist.precedence == pkg_resources.DEVELOP_DIST
and location != zc.buildout.easy_install.python_lib
and not isinstance(dist, pkg_resources.DistInfoDistribution)):
result.append(dist.project_name + '-' + _dir_hash(location))
if _is_develop(dist):
result.append(dist.project_name + '-' + _dir_hash(dist.location))
else:
result.append(dist.project_name + '-' + dist.version)
return result
......
......@@ -1178,6 +1178,7 @@ def _detect_distutils_scripts(egg_name, directory):
_develop_distutils_scripts[egg_name] = scripts_found
DEVELOP_INSTALLER = 'buildout:develop'
def develop(setup, dest, build_ext=None, executable=None, verbosity=-10):
if executable is not None: # BBB
assert executable == sys.executable, (executable, sys.executable)
......@@ -1313,6 +1314,10 @@ def develop(setup, dest, build_ext=None, executable=None, verbosity=-10):
"Falling back to project's root directory"
% (directory, packages),)
import_path = directory
# Mark this dist as installed by buildout as develop
if entry.endswith('.dist-info'):
with open(os.path.join(entry_path, 'INSTALLER'), 'w') as f:
f.write(DEVELOP_INSTALLER)
# Move the .dist-info folder to the import path like setuptools.
move(entry_path, os.path.join(import_path, project_name + ext))
# Create a temporary .egg-link.
......
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