Commit 49dbfac4 authored by Thomas Leymonerie's avatar Thomas Leymonerie

slapos/recipe/test_recipe.py : Add option python_path

parent 3f37cbc7
import os
from slapos.recipe.librecipe import GenericBaseRecipe
import slapos.slap
import subprocess
import zc.buildout.easy_install
class Recipe(GenericBaseRecipe):
_WORKING_SET_CACHE_NAME = "slapos.cookbook_pplugin_ws_cache"
def __init__(self, buildout, name, options):
options['path'] = os.path.join(
buildout['buildout']['parts-directory'],
......@@ -17,31 +14,7 @@ class Recipe(GenericBaseRecipe):
options['eggs-directory'] = buildout_section['eggs-directory']
options['develop-eggs-directory'] = buildout_section['develop-eggs-directory']
def _get_cache_storage(self):
"""Return a mapping where to store generated working sets.
from https://github.com/buildout/buildout/blob/master/zc.recipe.egg_/src/zc/recipe/egg/egg.py#L170
"""
try:
return getattr(self.buildout, self._WORKING_SET_CACHE_NAME)
except AttributeError:
cache_storage = {}
try:
setattr(
self.buildout,
self._WORKING_SET_CACHE_NAME,
cache_storage
)
except AttributeError:
if not isinstance(self.buildout, dict):
raise
# failed to set attribute in test mode, cache not used
return cache_storage
def install(self):
'''self.options.created(self.options['path'])
with open(self.options['path'], 'w') as f:
f.write(self.options['contents'])
return self.options.created()'''
develop_eggs_dir = self.options['develop-eggs-directory']
eggs_dir = self.options['eggs-directory']
egg_list = tuple(
......@@ -49,27 +22,15 @@ class Recipe(GenericBaseRecipe):
for egg in self.options['eggs'].splitlines()
if egg.strip()
)
cache_storage = self._get_cache_storage()
cache_key = (
egg_list,
eggs_dir,
develop_eggs_dir,
)
try:
working_set = cache_storage[cache_key]
except KeyError:
if develop_eggs_dir and eggs_dir:
working_set = zc.buildout.easy_install.working_set(
egg_list,
[develop_eggs_dir, eggs_dir]
)
cache_storage[cache_key] = working_set
else:
working_set = set()
test = pformat(tuple(dist.location for dist in working_set), indent=2)
print("/\---------/\ ")
self.options['test'] = "test"
print(self.options)
print("/\---------/\ ")
else: working_set = set()
python_path = ":".join(tuple(dist.location for dist in working_set))
self.options['python_path'] = python_path
update = install
\ No newline at end of file
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