Commit 5b3a22be 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 644c29e9
...@@ -2322,6 +2322,25 @@ def _dir_hash(dir): ...@@ -2322,6 +2322,25 @@ def _dir_hash(dir):
_dir_hashes[dir] = dir_hash = hash.hexdigest() _dir_hashes[dir] = dir_hash = hash.hexdigest()
return dir_hash 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): def _dists_sig(dists):
seen = set() seen = set()
result = [] result = []
...@@ -2329,11 +2348,8 @@ def _dists_sig(dists): ...@@ -2329,11 +2348,8 @@ def _dists_sig(dists):
if dist in seen: if dist in seen:
continue continue
seen.add(dist) seen.add(dist)
location = dist.location if _is_develop(dist):
if (dist.precedence == pkg_resources.DEVELOP_DIST result.append(dist.project_name + '-' + _dir_hash(dist.location))
and location != zc.buildout.easy_install.python_lib
and not isinstance(dist, pkg_resources.DistInfoDistribution)):
result.append(dist.project_name + '-' + _dir_hash(location))
else: else:
result.append(dist.project_name + '-' + dist.version) result.append(dist.project_name + '-' + dist.version)
return result return result
......
...@@ -1178,6 +1178,7 @@ def _detect_distutils_scripts(egg_name, directory): ...@@ -1178,6 +1178,7 @@ def _detect_distutils_scripts(egg_name, directory):
_develop_distutils_scripts[egg_name] = scripts_found _develop_distutils_scripts[egg_name] = scripts_found
DEVELOP_INSTALLER = 'buildout:develop'
def develop(setup, dest, build_ext=None, executable=None, verbosity=-10): def develop(setup, dest, build_ext=None, executable=None, verbosity=-10):
if executable is not None: # BBB if executable is not None: # BBB
assert executable == sys.executable, (executable, sys.executable) assert executable == sys.executable, (executable, sys.executable)
...@@ -1309,6 +1310,10 @@ def develop(setup, dest, build_ext=None, executable=None, verbosity=-10): ...@@ -1309,6 +1310,10 @@ def develop(setup, dest, build_ext=None, executable=None, verbosity=-10):
"Falling back to project's root directory" "Falling back to project's root directory"
% (directory, packages),) % (directory, packages),)
import_path = directory 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 the .dist-info folder to the import path like setuptools.
move(entry_path, os.path.join(import_path, project_name + ext)) move(entry_path, os.path.join(import_path, project_name + ext))
# Create a temporary .egg-link. # 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