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

_name=hyperqueue
pkgbase=$_name-git
pkgname=($pkgbase python-$pkgbase)
pkgver=0.22.0.r15.g99a27a2
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=(
  # 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
)
b2sums=('SKIP')

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

prepare() {
  cd $_name
  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() {
  # fix building with LTO
  CFLAGS+=' -ffat-lto-objects'

  cd $_name
  cargo build --frozen --release --all-features

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

check() {
  cd $_name
  cargo test --frozen --release --all-features

  # 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/hq.bash
  $_target generate-completion elvish | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/elvish/lib/hq.elv
  $_target generate-completion fish   | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/fish/vendor_completions.d/hq.fish
  $_target generate-completion zsh    | install -vDm 644 /dev/stdin "$pkgdir"/usr/share/zsh/site-functions/_hq
}

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
  python -m installer --destdir "$pkgdir" target/wheels/*.whl
  install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}