[buildout]
extends =
  ../../stack/slapos.cfg
  ../../component/numpy/buildout.cfg

parts =
  slapos-cookbook
  template

[python]
part = python3

[template]
recipe = slapos.recipe.template:jinja2
rendered = ${buildout:directory}/template.cfg
template =
  inline:[buildout]
  eggs-directory = ${buildout:eggs-directory}
  develop-eggs-directory = ${buildout:develop-eggs-directory}
  parts = runTestSuite

  [slap-configuration]
  recipe = slapos.cookbook:slapconfiguration.serialised
  computer = $${slap-connection:computer-id}
  partition = $${slap-connection:partition-id}
  url = $${slap-connection:server-url}
  key = $${slap-connection:key-file}
  cert = $${slap-connection:cert-file}

  [directory]
  recipe = slapos.cookbook:mkdirectory
  bin = $${buildout:directory}/bin
  tmp = $${buildout:directory}/tmp

  [runTestSuite]
  recipe = slapos.recipe.template:jinja2
  rendered = $${directory:bin}/$${:_buildout_section_name_}
  template = ${runTestSuite.in:target}
  mode = 0755
  context =
    key tmpdir directory:tmp
    key slapparameter_dict slap-configuration:configuration
    key cython_repository cython-repository:location
    raw runTestSuite_py ${runTestSuite_py:bin-directory}/${runTestSuite_py:interpreter}
    raw cython_env_sh ${cython_env.sh:rendered}

  [cython-repository]
  recipe = slapos.recipe.build:gitclone
  repository = ${cython-repository:location}
  git-executable = ${git:location}/bin/git
  shared = true

[cython-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/cython.git
git-executable = ${git:location}/bin/git
sparse-checkout = /.gitignore

[runTestSuite.in]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}
md5sum = 02094e80cde9631081077fc96b401065

[runTestSuite_py]
recipe = zc.recipe.egg
eggs = erp5.util
interpreter = ${:_buildout_section_name_}

[eggs]
recipe = zc.recipe.egg
eggs =
  ${numpy:egg}
  coverage
  pycodestyle

[cython_env.sh]
recipe = slapos.recipe.template:jinja2
rendered = ${buildout:directory}/${:_buildout_section_name_}
template =
  inline:{% set path, python = os.path.split(python) -%}
  {% if 'part' in gcc -%}
  {%   set path = path + ':' + gcc.prefix + '/bin' -%}
  {% endif -%}
  export PATH={{ path }}:$PATH
  export PYTHON={{ python }}
  export PYTHONPATH={{ ':'.join(easy_install.working_set(eggs['eggs'].split(), [
      eggs['develop-eggs-directory'],
      eggs['eggs-directory'],
    ]).entries) }}$${PYTHONPATH:+:$PYTHONPATH}
  # EmbedTest needs libintl.
  export LD_RUN_PATH={{ gettext }}/lib$${LD_RUN_PATH:+:$LD_RUN_PATH}
  export LIBRARY_PATH={{ gettext }}/lib$${LIBRARY_PATH:+:$LIBRARY_PATH}
  {##}
context =
  section eggs eggs
  section gcc gcc
  key gettext gettext:location
  key python python:executable
  import os os
  import easy_install zc.buildout.easy_install

[versions]
slapos.recipe.template = 4.4
coverage = 4.5.1
numpy = 1.16.4
pycodestyle = 2.5.0
