summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5165806cc797a6c24fdd3089150f01d43c4ff450 (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
# Maintainer: Josh Holmer <jholmer.in@gmail.com>

_plug=mlrt
pkgname=vapoursynth-plugin-${_plug}-trt-runtime-git
pkgver=811.1f166ba
pkgrel=2
pkgdesc="Plugin for VapourSynth: ${_plug} (TensorRT runtime: recommended for Nvidia GPUs >=8GB VRAM)"
arch=('x86_64')
url='https://github.com/AmusementClub/vs-mlrt'
license=('LGPL')
depends=('vapoursynth' 'cuda' 'tensorrt')
makedepends=('git' 'ninja' 'cmake' 'jq' 'vapoursynth-api3-headers')
provides=("vapoursynth-plugin-${_plug}")
conflicts=("vapoursynth-plugin-${_plug}")

# Function to fetch the latest release version
get_latest_release_version() {
	curl --silent "https://api.github.com/repos/AmusementClub/vs-mlrt/releases/latest" | jq -r .tag_name
}

# Fetch the latest release version
latest_release=$(get_latest_release_version)

source=("${_plug}::git+https://github.com/AmusementClub/vs-mlrt.git"
	"models-${latest_release}.7z::https://github.com/AmusementClub/vs-mlrt/releases/download/${latest_release}/models.${latest_release}.7z")
sha256sums=('SKIP' 'SKIP')

pkgver() {
	cd "${_plug}"

	_rev=$(git rev-list --count --all)
	_hash=$(git rev-parse --short HEAD)
	printf "%s.%s" "$_rev" "$_hash"
}

build() {
	cmake -S "${_plug}/vstrt" -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DVAPOURSYNTH_INCLUDE_DIRECTORY="/usr/include/vapoursynth" \
		-DCMAKE_CXX_FLAGS="${CXXFLAGS} -ffast-math"

	cmake --build build
}

package() {
	site_packages="$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')"
	PLUGINDIR=$(python -c "import vapoursynth; print(vapoursynth.get_plugin_dir())")

	# The cmake script puts the library inside a `lib` dir, which we don't want, so we have to install it manually
	install -Dm755 "build/libvstrt.so" "${pkgdir}${PLUGINDIR}/libvstrt.so"
	for i in $(find models* -type f); do install -Dm644 "${i}" "${pkgdir}${PLUGINDIR}/${i}"; done

	# For some reason this plugin wants to look for trtexec at ${PLUGINDIR}/vsmlrt-cuda/trtexec
	# instead of in PATH, so we have to symlink it there from the tensorrt package.
	mkdir -p "${pkgdir}${PLUGINDIR}/vsmlrt-cuda"
	ln -s /usr/bin/trtexec "${pkgdir}${PLUGINDIR}/vsmlrt-cuda/trtexec"

	install -Dm644 "${_plug}/scripts/vsmlrt.py" "${pkgdir}${site_packages}/vsmlrt.py"

	install -Dm644 "${_plug}/README.md" "${pkgdir}/usr/share/doc/vapoursynth/tools/${_plug}/README.md"
	install -Dm644 "${_plug}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}