summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c273d5ca81e5eaac2f5de544ae314de9b69e6126 (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
86
87
88
89
90
91
92
# Maintainer: Butui Hu <hot123tea123@gmail.com>

_pkgname=decord
pkgname=('python-decord' 'python-decord-cuda')
pkgver=0.6.0
pkgrel=7
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-2.0')
depends=(
  ffmpeg4.4
  glibc
  gcc-libs
  python-numpy
)
makedepends=(
  chrpath
  cmake
  cuda
  cython
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
  chrpath
)
source=("${_pkgname}-${pkgver}::git+https://github.com/dmlc/decord.git#tag=v${pkgver}"
        "0001-fix-building-with-ffmpeg4.4.patch"
)
sha512sums=('f91944e7931f18576cdedd69edc9f651189db2dbc63e7f211cb894cea71bc9df0f4f83ef27f2449da4c9cf13517c310ed0ef6bdd01d01f48258e0f7bf3efa027'
            'e4b8450ee48583b40f99bf9c981e1f37529c16ba002f6781187621fb6b94d3856db34e90c4c1fd88978601deb88d1e0d31f161232882651c6c6cd61dd91da45a')

prepare() {
  cd "${_pkgname}-${pkgver}"
  git submodule update --init --recursive
  # fix building with ffmpeg4.4
  patch -p1 -i ${srcdir}/0001-fix-building-with-ffmpeg4.4.patch
  cp -a "${srcdir}/${_pkgname}-${pkgver}" "${srcdir}/${_pkgname}-cuda-${pkgver}"
}

build() {
  # building without CUDA
  cmake \
    -B "${srcdir}/${_pkgname}-${pkgver}/build" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_SKIP_INSTALL_RPATH=ON \
    -DFFMPEG_DIR=/usr \
    -DUSE_CUDA=OFF \
    -S "${srcdir}/${_pkgname}-${pkgver}"
  make -C "${srcdir}/${_pkgname}-${pkgver}/build" VERBOSE=1
  cd "${srcdir}/${_pkgname}-${pkgver}/python"
  python -m build --wheel --no-isolation

  # building with CUDA
  cmake \
    -B "${srcdir}/${_pkgname}-cuda-${pkgver}/build" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_CXX_COMPILER=/opt/cuda/bin/g++ \
    -DCMAKE_C_COMPILER=/opt/cuda/bin/gcc \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_SKIP_INSTALL_RPATH=ON \
    -DFFMPEG_DIR=/usr \
    -DUSE_CUDA=ON \
    -S "${srcdir}/${_pkgname}-cuda-${pkgver}"
  make -C "${srcdir}/${_pkgname}-cuda-${pkgver}/build" VERBOSE=1
  cd "${srcdir}/${_pkgname}-cuda-${pkgver}/python"
  python -m build --wheel --no-isolation
}

package_python-decord() {
  cd "${srcdir}/${_pkgname}-${pkgver}/python"
  python -m installer --destdir="${pkgdir}" dist/*.whl
}

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

  cd "${srcdir}/${_pkgname}-cuda-${pkgver}/python"
  python -m installer --destdir="${pkgdir}" dist/*.whl
  find ${pkgdir} -type f -name "*.so" -exec chrpath --delete {} \;
}
# vim:set ts=2 sw=2 et: