summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1ddc17d055c35b6643cea80092bd5b3cb02d4699 (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
133
134
135
136
# Maintainer: Jakub Klinkovský <lahwaacz at archlinux dot org>

_name=hyperqueue
pkgbase=$_name-git
pkgname=($pkgbase python-$pkgbase)
pkgver=0.25.0.r7.g50cd7b5
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-typing_extensions
  python-ruff
)
source=(
  git+$url
)
b2sums=('SKIP')

# deselect highs from default features
# https://github.com/It4innovations/hyperqueue/issues/1066#issuecomment-3968989734
_cargo_features_flags=(--no-default-features --features dashboard,jemalloc,microlp)
_maturin_features_flags=(--no-default-features --features microlp)

pkgver() {
  cd $_name
  git describe --long --tags --abbrev=7 --exclude=nightly --exclude=-rc | 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

  # avoid test failure due to slow domain resolution of non-existing hostname
  # see https://github.com/It4innovations/hyperqueue/issues/963
  sed -i 's|"nonexistingx:1"|"localhost:1"|' crates/tako/src/internal/datasrv/tests.rs
}

build() {
  # fix building with LTO
  CFLAGS+=' -ffat-lto-objects'

  cd $_name
  cargo build --frozen --release "${_cargo_features_flags[@]}"

  # build Python bindings
  cd crates/pyhq
  maturin build --locked --release --target "$(rustc --print host-tuple)" --strip "${_maturin_features_flags[@]}"
}

check() {
  cd $_name
  cargo test --frozen --release "${_cargo_features_flags[@]}"

  # 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=(
    glibc
    libgcc
  )
  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=(
    glibc
    hyperqueue
    libgcc
    # 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/
}