summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1a199a756dee77d8d1b84e43a3456b7fe553c282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Maintainer: TheFeelTrain <the@feeltra.in>
# Contributor: Josh Holmer <jholmer.in@gmail.com>

pkgname=python-videotimestamps
_origpkgname=videotimestamps
pkgver=1.3.0
pkgrel=2
pkgdesc="Get video timestamps."
arch=("x86_64")
url='https://github.com/moi15moi/VideoTimestamps/'
license=("MIT")
depends=(
  "ffmpeg"
  "ffms2-git"
  "dav1d"
  "python-xxhash"
  "xxhash"
  "vapoursynth-plugin-bestsource"
)
makedepends=(
  "meson"
  "meson-python"
  "python-build"
  "python-installer"
  "python-wheel"
  "python-setuptools"
  "nanobind"
  "robin-map"
  "vapoursynth"
)
source=("https://files.pythonhosted.org/packages/source/v/${_origpkgname}/${_origpkgname}-${pkgver}.tar.gz")
sha256sums=('817fb019dd39c860314e53c745c4ef73e733ad3734dddee92e2059463b41b4cf')

prepare() {
  cd "${_origpkgname}-${pkgver}" || exit

  # Prefer the system libraries over the forced fallback subprojects.
  sed -i 's/--default-library=static/--default-library=shared/g' pyproject.toml
  sed -i 's/--wrap-mode=forcefallback/--wrap-mode=default/g' pyproject.toml

  # The bestsource subproject is only used for its headers; the library itself comes from vapoursynth-plugin-bestsource
  meson subprojects download bestsource

  # meson cannot probe nanobind's CMake package so expose the system headers through pkg-config and build nanobind's implementation source into each extension module.
  local nanobind_inc nanobind_ver
  nanobind_inc="$(python -c 'import nanobind; print(nanobind.include_dir())')"
  nanobind_ver="$(python -c 'import nanobind; print(nanobind.__version__)')"
  sed -i "/^nanobind_dep = dependency('nanobind')$/a nanobind_dep = declare_dependency(dependencies: nanobind_dep, sources: files(run_command(py, '-c', 'import nanobind; print(nanobind.source_dir() + \"/nb_combined.cpp\")', check: true).stdout().strip()))" meson.build

  # vapoursynth-plugin-bestsource does not have headers nor a pkg-config file 
  # feed meson's dependency('bestsource') a stub that points at the system shared library plus the headers downloaded above
  local plugins_dir
  plugins_dir="$(python -c 'import os, vapoursynth; print(os.path.join(os.path.dirname(vapoursynth.__file__), "plugins"))')"
  cat > bestsource.pc <<EOF
includedir=${srcdir}/${_origpkgname}-${pkgver}/subprojects/bestsource/src
pluginsdir=${plugins_dir}

Name: bestsource
Description: A super great audio/video source and FFmpeg wrapper
Version: 22.0
Cflags: -I\${includedir}
Libs: -L\${pluginsdir} -lbestsource -Wl,-rpath,\${pluginsdir}
EOF

  cat > nanobind.pc <<EOF
includedir=${nanobind_inc}

Name: nanobind
Description: nanobind C++/Python bindings
Version: ${nanobind_ver}
Cflags: -I\${includedir}
EOF
}

build() {
  cd "${_origpkgname}-${pkgver}" || exit
  export PKG_CONFIG_PATH="$srcdir/${_origpkgname}-${pkgver}${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
  python -m build --wheel --no-isolation
}

package() {
  cd "${_origpkgname}-${pkgver}" || exit
  python -m installer --destdir="$pkgdir" dist/*.whl
}