[buildout]
parts =

[macro.pythonpath.eggs]
recipe = slapos.recipe.build
_name_ = ${:_buildout_section_name_}
init =
  prerequisite = """
  [.%(_name_)s.prerequisite]
  recipe = slapos.recipe.build
  init =
    section = self.buildout['%(_name_)s']
    self.eggs = [e.strip() for e in section['eggs'].splitlines() if e.strip()]
  update =
    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])
    paths = ':'.join(dist.location for dist in dists)
    self.buildout['%(environment)s']['PYTHONPATH'] = paths
    print("PYTHONPATH=" + paths)
  """ % options
  self.buildout.parse(prerequisite)
