Commit b78c33af authored by Xavier Thompson's avatar Xavier Thompson

[feat] Propagate libnetworkcache installation

If slapos.libnetworkcache is importable, install it in bootstrap and
in buildout upgrade - the places where bin/buildout is (re)generated
- as though it were a dependency of zc.buildout.

This is a hack to propagate libnetworkcache as a soft dependency.
parent 2e3258e9
...@@ -710,6 +710,14 @@ class Buildout(DictMixin): ...@@ -710,6 +710,14 @@ class Buildout(DictMixin):
self._setup_directories() self._setup_directories()
# Hack: propagate libnetworkcache soft dependency
specs = ['zc.buildout']
try:
import slapos.libnetworkcache
specs.append('slapos.libnetworkcache')
except ImportError:
pass
# Install buildout and dependent eggs following pinned versions. # Install buildout and dependent eggs following pinned versions.
dest = self['buildout']['eggs-directory'] dest = self['buildout']['eggs-directory']
path = [self['buildout']['develop-eggs-directory']] path = [self['buildout']['develop-eggs-directory']]
...@@ -718,7 +726,7 @@ class Buildout(DictMixin): ...@@ -718,7 +726,7 @@ class Buildout(DictMixin):
path.append(dest) path.append(dest)
dest = None dest = None
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
['zc.buildout'], specs,
dest, dest,
links=self._links, links=self._links,
index=self['buildout'].get('index'), index=self['buildout'].get('index'),
...@@ -1296,8 +1304,17 @@ class Buildout(DictMixin): ...@@ -1296,8 +1304,17 @@ class Buildout(DictMixin):
if not self.newest: if not self.newest:
return return
# Hack: propagate libnetworkcache soft dependency
# XXX just zc.buildout should suffice, then iter over projects in ws
specs = ['zc.buildout', 'setuptools', 'pip', 'wheel']
try:
import slapos.libnetworkcache
specs.append('slapos.libnetworkcache')
except ImportError:
pass
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
('zc.buildout', 'setuptools', 'pip', 'wheel'), specs,
self['buildout']['eggs-directory'], self['buildout']['eggs-directory'],
links = self['buildout'].get('find-links', '').split(), links = self['buildout'].get('find-links', '').split(),
index = self['buildout'].get('index'), index = self['buildout'].get('index'),
...@@ -1307,7 +1324,7 @@ class Buildout(DictMixin): ...@@ -1307,7 +1324,7 @@ class Buildout(DictMixin):
upgraded = [] upgraded = []
for project in 'zc.buildout', 'setuptools', 'pip', 'wheel': for project in specs:
req = pkg_resources.Requirement.parse(project) req = pkg_resources.Requirement.parse(project)
dist = ws.find(req) dist = ws.find(req)
importlib.import_module(project) importlib.import_module(project)
......
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