pkgname=pybind11
pkgver=3.0.1
pkgdesc='A lightweight header-only library that exposes C++ types in Python and vice versa'
arch=('any')
homepage='https://pybind11.readthedocs.org/'
license=('BSD-3-Clause')
depends=('python')
makedepends=(
    'cmake'
    'eigen'
    'python-build'
    'python-installer'
    'python-scikit-build-core'
    'python-wheel')
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/pybind/pybind11/archive/v${pkgver}/${sources[0]}")
md5sums=("81399a5277559163b3ee912b41de1b76")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  python -m build --wheel --no-isolation
}

src_install() {
  python -m installer --destdir="$pkgdir" dist/*.whl

  local _sitepkgs
  _sitepkgs="$(python -c 'import site; print(site.getsitepackages()[0])')"
  install -d -m755 "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -sr "${pkgdir}${_sitepkgs}/pybind11-${pkgver}.dist-info/licenses/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  install -d -m755 "${pkgdir}/usr"/{include,lib/{cmake,pkgconfig}}
  ln -sr "${pkgdir}${_sitepkgs}/pybind11/include/pybind11" "${pkgdir}/usr/include/pybind11"
  ln -sr "${pkgdir}${_sitepkgs}/pybind11/share/cmake/pybind11" "${pkgdir}/usr/lib/cmake/pybind11"
  ln -sr "${pkgdir}${_sitepkgs}/pybind11/share/pkgconfig/pybind11.pc" "${pkgdir}/usr/lib/pkgconfig/pybind11.pc"
}

# vim:ft=sh syn=sh et sw=2:
