summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9079c033b3c6b1acf7280ec3d177e7569ed8a951 (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
85
# Maintainer: Butui Hu <hot123tea123@gmail.com>

_pkgname=decord
pkgname=('python-decord' 'python-decord-cuda')
pkgver=0.6.0
pkgrel=5
pkgdesc="An efficient video loader for deep learning with smart shuffling that's super easy to digest"
arch=('x86_64')
url='https://github.com/dmlc/decord'
license=('Apache')
depends=(
  ffmpeg
  libavcodec.so
  libavfilter.so
  libavformat.so
  libavutil.so
  libswresample.so
  python-numpy
)
makedepends=(
  chrpath
  cmake
  cuda
  cython
  gcc12
  git
  python-setuptools
)
source=("${_pkgname}-${pkgver}::git+https://github.com/dmlc/decord.git#tag=v${pkgver}")
sha512sums=('SKIP')

prepare() {
  cd "${_pkgname}-${pkgver}"
  git submodule update --init --recursive
  # fix building with ffmpeg
  sed -i "21i#include <libavcodec/bsf.h>" "src/video/ffmpeg/ffmpeg_common.h"
  # fix const pointer convert issue
  sed -i "s,AVCodec \*dec,const AVCodec \*dec," "src/video/video_reader.cc"
  sed -i "165s,fmt_ctx_,(AVInputFormat\*)fmt_ctx_," "src/video/video_reader.cc"
  cp -a "${srcdir}/${_pkgname}-${pkgver}" "${srcdir}/${_pkgname}-cuda-${pkgver}"
  # build with gcc12
  export CC=gcc-12
  export CXX=g++-12
}

build() {
  # building without CUDA
  cmake -B "${srcdir}/${_pkgname}-${pkgver}/build" -S "${srcdir}/${_pkgname}-${pkgver}" \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \
    -DUSE_CUDA:BOOL=OFF
  make -C "${srcdir}/${_pkgname}-${pkgver}/build"
  cd "${srcdir}/${_pkgname}-${pkgver}/python"
  python setup.py build

  # building with CUDA
  cmake -B "${srcdir}/${_pkgname}-cuda-${pkgver}/build" -S "${srcdir}/${_pkgname}-cuda-${pkgver}" \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \
    -DUSE_CUDA:BOOL=ON
  make -C "${srcdir}/${_pkgname}-cuda-${pkgver}/build"
  cd "${srcdir}/${_pkgname}-cuda-${pkgver}/python"
  python setup.py build
}

package_python-decord() {
  cd "${srcdir}/${_pkgname}-${pkgver}/python"
  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  mv -vf "${pkgdir}/usr/${_pkgname}/libdecord.so" "${pkgdir}/usr/lib"
  rm -rf "${pkgdir}/usr/${_pkgname}"
}

package_python-decord-cuda() {
  pkgdesc="${pkgdesc} (with CUDA)"
  depends+=(cuda libcudart.so)
  provides=(python-decord=${pkgver})
  conflicts=(python-decord)

  cd "${srcdir}/${_pkgname}-cuda-${pkgver}/python"
  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
  mv -vf "${pkgdir}/usr/${_pkgname}/libdecord.so" "${pkgdir}/usr/lib"
  chrpath --delete "${pkgdir}/usr/lib/libdecord.so"
  rm -rf "${pkgdir}/usr/${_pkgname}"
}
# vim:set ts=2 sw=2 et: