[buildout]
parts =

[macro.variable.eggs]
recipe = slapos.recipe.build
init =
  self.eggs = [e.strip() for e in options['eggs'].splitlines() if e.strip()]
update =
  import os
  from zc.buildout.easy_install import working_set
  buildout = self.buildout['buildout']
  eggs_directory = buildout['eggs-directory']
  develop_eggs_directory = buildout['develop-eggs-directory']
  dists = working_set(self.eggs, [develop_eggs_directory, eggs_directory])
  subpaths = dict(l.split() for l in options['subpaths'].splitlines())
  def make_path(dist):
    subpath = subpaths.get(dist.key)
    return os.path.join(dist.location, subpath) if subpath else dist.location
  paths = ':'.join(make_path(dist) for dist in dists)
  environment = self.buildout[options['environment']]
  variable = options['variable']
  value = environment.get(variable)
  if value:
    paths = '%s:%s' % (paths, value)
  environment[variable] = paths
  print("%s=%s" %(variable, paths))
variable = PYTHONPATH
subpaths =

[macro.pythonpath.eggs]
<= macro.variable.eggs
