summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: baa4f7c357c78a1ff1f18d104844488d7da49ec2 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Maintainer:

_pkgname="spleeter"
pkgname="$_pkgname-git"
pkgver=2.4.0.r36.g13c771b
pkgrel=1
pkgdesc="Deezer music source separation library and tool using pretrained models"
# https://research.deezer.com/projects/spleeter.html
url="https://github.com/deezer/spleeter"
arch=('any')
license=('MIT')

depends=(
  'python-h2' # (optdep python-httpx)
  'python-httpx'
  'python-numpy'
  'python-pandas'
  'python-tensorflow'
  'python-typer'
  'python-pyxdg'

  # AUR
  'python-ffmpeg-python'
  'python-norbert'
  'python-musdb'
      # python-soundfile
      # python-stempeg
  'python-museval'
      # python-musdb
      # python-soundfile
      # python-stempeg
          # python-soundfile
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-poetry'
  'python-wheel'
)
#checkdepends=(
#  'python-py'
#  'python-pytest'
#  'python-pytest-forked'
#)
optdepends=(
  'spleeter-data: pretrained model'
)

provides=(
  "$_pkgname"
)
conflicts=(${provides[@]})

options=("!strip")

source=(
  "$_pkgname"::"git+$url"
  'github-pr-808-rebased-2.3.0.patch'
  'xdg_config_home.patch'
)
sha256sums=(
  'SKIP'
  '50472de0822614939fe0fabd36439cc38f5ff35828c06121884f5e125e1845b6'
  '24a40f5fd3cbf87e2e78236159fefe60be6a02e895c50d8f7e17546f27e322e0'
)

prepare() {
  cd "$srcdir/$_pkgname"

  for patch in "$srcdir"/*.patch ; do
    if [ -f "$patch" ] ; then
      printf 'Applying patch: %s\n' "${patch##*/}"
      patch -Np1 -F100 -i "$patch"
    fi
  done
}

pkgver() {
  cd "$srcdir/$_pkgname"

  _regex='^version = "([0-9]+\.[0-9]+(\.[0-9]+)?)"$'
  _file="pyproject.toml"

  _line=$(
    grep -E "$_regex" "$_file" | head -1
  )
  _version=$(
    printf '%s' "$_line" | sed -E "s@$_regex@\1@"
  )
  _commit=$(
    git log -S "$_line" -1 --pretty=oneline --no-color -- "$_file" \
      | sed 's@\ .*$@@'
  )
  _revision=$(
    git rev-list --count $_commit..HEAD
  )
  _hash=$(
    git rev-parse --short HEAD
  )

  printf '%s.r%s.g%s' \
    "$_version" \
    "$_revision" \
    "$_hash"
}

build() {
  cd "$srcdir/$_pkgname"
  python -m build --wheel --no-isolation
}

#check() {
#  cd "$srcdir/$_pkgname"
#  rm -rf pretrained_models
#  python -m pytest
#}

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

  # install LICENSE
  install -vDm0644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"

  # remove incorrectly installed LICENSE file
  _pyver=$(python --version | sed -E 's@^Python\ ([0-9]+\\.[0-9]+)(\\.[0-9]+)?$@\1@')
  rm -f "$pkgdir/usr/lib/python$_pyver/site-packages/LICENSE"
}