summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e19d4ffe97dd65a6fc941fcc1dd7f991817e38f0 (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
130
131
132
# Maintainer: Jakub Klinkovský <lahwaacz at archlinux dot org>

_name=hyperqueue
pkgbase=$_name-git
pkgname=($pkgbase python-$pkgbase)
pkgver=0.21.0.r19.g832f245
pkgrel=1
pkgdesc="Scheduler for sub-node tasks for HPC systems with batch scheduling"
arch=(x86_64)
url="https://github.com/It4innovations/hyperqueue/"
license=(MIT)
makedepends=(
  git
  cargo
  maturin
  python-installer
  python-cloudpickle
  python-tqdm
  python-pydot
)
checkdepends=(
  # some tests run `hostname` https://github.com/It4innovations/hyperqueue/issues/808#issuecomment-2629060187
  inetutils
  # https://github.com/It4innovations/hyperqueue/blob/main/tests/requirements.txt
  python-pytest
  python-pytest-xdist
  python-iso8601
  python-schema
  python-maturin
  python-psutil
  python-requests
  python-aiohttp
  python-inline-snapshot
  python-ruff
)
source=(
  git+$url
  fix-pyhq.patch
)
b2sums=('SKIP'
        'b7727d0237b6a78f8a5db0e1bea21903c5bca1285baf1348985e0c9c9a91bd1a116c63e27a9060c6b730f1fdc241a12a8df40b7f3e77332a7a8f3ab6e60e89cc')

pkgver() {
  cd $_name
  git describe --long --tags --abbrev=7 --exclude=nightly | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd $_name
  # patch for Python 3.13 compatibility https://github.com/It4innovations/hyperqueue/pull/811
  patch -Np1 < ../fix-pyhq.patch

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"

  # run Python tests with the release binary
  sed -i 's|"target", directory, "hq"|"target", "release", "hq"|' tests/conftest.py
}

build() {
  cd $_name
  # does not work with jemalloc https://github.com/It4innovations/hyperqueue/issues/808#issuecomment-2628930149
  cargo build --frozen --release --no-default-features --features dashboard

  # build Python bindings
  cd crates/pyhq
  maturin build --locked --release --target "$(rustc -vV | sed -n 's/host: //p')" --strip
}

check() {
  cd $_name
  # does not work with jemalloc https://github.com/It4innovations/hyperqueue/issues/808#issuecomment-2628930149
  cargo test --frozen --no-default-features --features dashboard

  # test Python bindings
  local pytest_options=(
    -vv
    -W ignore::DeprecationWarning
    -n16
  )
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer target/wheels/*.whl
  # the tests use Python subprocess module to start hq which needs the same env in order for
  # submitted tasks to work, so we must actually activate the venv
  (
    source test-env/bin/activate
    python -m pytest "${pytest_options[@]}" tests
  )
}

package_hyperqueue-git() {
  depends=(
    gcc-libs
    glibc
  )
  conflicts=(hyperqueue)
  provides=(hyperqueue)

  cd $_name
  local _target="target/release/hq"

  # install the binary and license
  install -vDm 755 "$_target" -t "$pkgdir"/usr/bin/
  install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/

  # generate shell completions
  $_target generate-completion bash   | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/bash-completion/completions/$_name.bash
  $_target generate-completion elvish | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/elvish/lib/$_name.elv
  $_target generate-completion fish   | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/fish/vendor_completions.d/$_name.fish
  $_target generate-completion zsh    | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/zsh/site-functions/_$_name
}

package_python-hyperqueue-git() {
  pkgdesc+=" - Python bindings"
  depends=(
    gcc-libs
    glibc
    hyperqueue
    # https://github.com/It4innovations/hyperqueue/blob/main/crates/pyhq/pyproject.toml
    python
    python-cloudpickle
    python-tqdm
  )
  optdepends=(
    'python-pydot: task graph visualization'
  )
  conflicts=(python-hyperqueue)
  provides=(python-hyperqueue)

  cd $_name
  install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
  python -m installer -d "$pkgdir" target/wheels/*.whl
}