[buildout]
extends =
  ../python3/buildout.cfg
parts =
  meson

[meson]
recipe = slapos.recipe.cmmi
shared = true
url = https://github.com/mesonbuild/meson/releases/download/${:version}/meson-${:version}.tar.gz
version = 0.62.1
md5sum = 2f5301d0e7fd5544ab0004393ba44cbe
configure-command = true
make-binary = true
post-install =
  %(python)s -m venv %(location)s
  set %(location)s/bin/python3
  $1 setup.py install_data install_lib
  $1 <<EOF
  import os, pkg_resources, sys
  for name, ep in pkg_resources.get_entry_map(
      'meson==%(version)s', 'console_scripts').items():
    fd = os.open(%(location)r '/bin/' + name, os.O_WRONLY|os.O_CREAT|os.O_EXCL)
    os.write(fd, ("""#!$1
  import os, sys
  from %%s import %%s
  if __name__ == '__main__':
    sys.exit(%%s())
  """ %% (ep.module_name, ep.attrs[0], '.'.join(ep.attrs))).encode())
    os.close(fd)
  EOF
  %(location)s/bin/pip uninstall -y pip setuptools
python = ${python3:executable}

[meson:python3]
python = ${buildout:executable}
