[buildout]

extends =
  ../pkgconfig/buildout.cfg
  ../gtk-3/buildout.cfg
  ../pillow/buildout.cfg
  ../numpy/buildout.cfg
  ../wxwidgets/buildout.cfg

parts =
    wxPython

[wxpython-eggs]
recipe = zc.recipe.egg
interpreter = wxpython2.7
eggs =
  requests
  ${numpy:egg}
  ${pillow-python:egg}

[nanosvg]
recipe = slapos.recipe.build:download-unpacked
shared = true
url = https://github.com/wxWidgets/nanosvg/archive/${:version}.tar.gz
version = 9dd92bbfc6f709e889578a724724ffbd42ac3004
md5sum = b9060d6600ebffa4080d1b29c99d1f30

[wxPython-download]
recipe = slapos.recipe.build:download-unpacked
url = https://github.com/wxWidgets/Phoenix/archive/refs/tags/wxPython-4.1.1.tar.gz
md5sum = e72d99cd865c4220b65065079457c6c5

[wxPython]
recipe = slapos.recipe.build
egg = ${:_buildout_section_name_}
source-location = ${wxPython-download:location}
egg-name = ${:egg}-${versions:wxPython}-py${python:version}-linux-x86_64.egg
location = ${buildout:eggs-directory}/${:egg-name}
python-bin = ${buildout:bin-directory}/${wxpython-eggs:interpreter}
ext-path = ${wxWidgets:location}/${wxWidgets:ext-name}
install =
  import os, sys
  from slapos.recipe.downloadunpacked import unpack_archive
  from zc.buildout import easy_install
  env = self.environ
  workdir = options['source-location']
  python_bin = options['python-bin']
  dist = os.path.join(workdir, 'dist')
  build = os.path.join(workdir, 'build')
  doxygen = os.path.join(workdir, 'bin', 'doxygen-1.8.8-linux')
  sip = os.path.join(workdir, 'bin', 'sip-4.19.24-linux64')
  waf = os.path.join(workdir, 'bin', 'waf-2.0.19')
  wxwidget = os.path.join(workdir, 'ext', 'wxWidgets')
  wxpython_eggs = self.buildout['wxpython-eggs']
  egg_list = easy_install.working_set(wxpython_eggs['eggs'].split(), [
    wxpython_eggs['develop-eggs-directory'],
    wxpython_eggs['eggs-directory'],
  ]).entries
  egg_list.append(workdir)
  env['PYTHONPATH'] = os.pathsep.join(sys.path + egg_list)
  self.cleanup_list += build, dist, doxygen, sip, waf, wxwidget
  unpack_archive(self, options['ext-path'], wxwidget)
  call([python_bin, 'build.py', 'dox', 'etg', '--nodoc', 'sip', 'build', '--use_syswx', '--release',
        '--gtk3'], env=env, cwd=workdir)
  call([python_bin, 'build.py', 'bdist_egg', '--use_syswx', '--release',
        '--gtk3'], env=env, cwd=workdir)
  unpack_archive(self, os.path.join(dist, options['egg-name']), location)
  call([python_bin, 'build.py', 'clean'], env=env, cwd=workdir)
environment =
  PATH=${xz-utils:location}/bin:${pkgconfig:location}/bin:${wxWidgets:location}/bin:%(PATH)s
  LDFLAGS=-L${gtk-3:location}/lib -Wl,-rpath=${gtk-3:location}/lib -L${wxWidgets:location}/lib -Wl,-rpath=${wxWidgets:location}/lib
  CPPFLAGS=-I${wxWidgets:location}/include/wx-3.0 -I${wxWidgets:location}/lib/wx/include/gtk3-unicode-3.0 -I${gtk-3:location}/include/gtk-3.0 -I${nanosvg:location}/src
  PKG_CONFIG_PATH = ${glib:location}/lib/pkgconfig:${gtk-3:location}/lib/pkgconfig:${gtk-3:pkg_config_depends}

[versions]
wxPython = 4.1.1
