makedepends=(cmake git imath python-build python-packaging python-installer python-setuptools python-wheel)
run=(python)

description="Open Source API and interchange format for editorial timeline information"
url="http://opentimeline.io/"

packager="Great-OS Team"
maintainer="Great-OS Team"

name="opentimelineio"
version="0.18.1"
release=1

source=(https://github.com/AcademySoftwareFoundation/OpenTimelineIO/archive/refs/tags/v${version}.tar.gz)

prepare() { 
  cd OpenTimelineIO-${version}
  
  git clone https://github.com/Tencent/rapidjson src/deps/rapidjson

  git clone https://github.com/pybind/pybind11 src/deps/pybind11

  git clone https://github.com/AcademySoftwareFoundation/Imath src/deps/Imath

  sed -e '/cmake/d' -i pyproject.toml
}

build() { 
  cmake -B build -S OpenTimelineIO-${version} -DCMAKE_INSTALL_PREFIX=/usr -DOTIO_FIND_IMATH=ON -DOTIO_AUTOMATIC_SUBMODULES=OFF -DOTIO_DEPENDENCIES_INSTALL=OFF

  cmake --build build

  export CXXFLAGS+=" -I/usr/include/Imath"

  cd OpenTimelineIO-${version}

  python3 -m build --wheel --no-isolation
}

package() {
  DESTDIR="$PKG" cmake --install build

  cd OpenTimelineIO-${version}

  python3 -m installer --destdir="$PKG" dist/*.whl

  rm -fr "$PKG"/build
}
