Commit 5d5ebff6 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify detection of libnetworkcache.

parent 4a184955
...@@ -40,6 +40,12 @@ import zc.buildout ...@@ -40,6 +40,12 @@ import zc.buildout
import zc.buildout.download import zc.buildout.download
import zc.buildout.easy_install import zc.buildout.easy_install
try:
import slapos.libnetworkcache
except ImportError:
LIBNETWORKCACHE_ENABLED = False
else:
LIBNETWORKCACHE_ENABLED = True
realpath = zc.buildout.easy_install.realpath realpath = zc.buildout.easy_install.realpath
...@@ -345,11 +351,7 @@ class Buildout(UserDict.DictMixin): ...@@ -345,11 +351,7 @@ class Buildout(UserDict.DictMixin):
# Get a base working set for our distributions that corresponds to the # Get a base working set for our distributions that corresponds to the
# stated desires in the configuration. # stated desires in the configuration.
distributions = ['setuptools', 'zc.buildout'] distributions = ['setuptools', 'zc.buildout']
try: if LIBNETWORKCACHE_ENABLED:
import slapos.libnetworkcache
except ImportError:
pass
else:
distributions.append('slapos.libnetworkcache') distributions.append('slapos.libnetworkcache')
if options.get('offline') == 'true': if options.get('offline') == 'true':
ws = zc.buildout.easy_install.working_set( ws = zc.buildout.easy_install.working_set(
...@@ -375,11 +377,7 @@ class Buildout(UserDict.DictMixin): ...@@ -375,11 +377,7 @@ class Buildout(UserDict.DictMixin):
# Now copy buildout and setuptools eggs, and record destination eggs: # Now copy buildout and setuptools eggs, and record destination eggs:
entries = [] entries = []
copy_list = ['setuptools', 'zc.buildout'] copy_list = ['setuptools', 'zc.buildout']
try: if LIBNETWORKCACHE_ENABLED:
import slapos.libnetworkcache
except ImportError:
pass
else:
copy_list.append('slapos.libnetworkcache') copy_list.append('slapos.libnetworkcache')
for name in copy_list: for name in copy_list:
r = pkg_resources.Requirement.parse(name) r = pkg_resources.Requirement.parse(name)
......
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