blob: 0d543b51fa7cf83f87599e5c05d7d351cc85bec3 (
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
|
# Maintainer: Jakub Klinkovský <lahwaacz at archlinux dot org>
_name=pytnl
pkgbase=python-$_name
pkgname=($pkgbase $pkgbase-cuda)
pkgver=0.0.13
pkgrel=1
pkgdesc="Python bindings for the Template Numerical Library"
arch=(x86_64)
url="https://gitlab.com/tnl-project/pytnl"
license=(MIT)
depends=(
glibc
libgcc
libgomp
libstdc++
openmpi
python
tinyxml2
zlib
)
makedepends=(
cmake
cuda
git
python-build
python-installer
python-scikit-build-core
)
checkdepends=(
python-pytest
python-pytest-xdist
python-psutil
python-hypothesis
python-mpi4py
python-numpy
)
source=($url/-/archive/$pkgver/$_name-$pkgver.tar.gz)
b2sums=('d8bf3db3bb708524eb2f52c7593e24431615c7899a81bf4abbe6e96844757dd4b06f8bd4709f3a842d5ea9578ab8eee5a97db7db1349d5ca4af40842f49fb0bf')
_pick() {
local p="$1" f d; shift
for f; do
d="$srcdir/$p/${f#$pkgdir/}"
mkdir -p "$(dirname "$d")"
mv "$f" "$d"
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
done
}
build() {
# In general, we want to list all real archs (sm_XX) and the latest virtual arch (compute_XX) for future PTX compatibility.
# Valid values can be discovered from nvcc --help
local cuda_archs="75;80;86;87;88;89;90;100;103;110;120;121;121-virtual"
# Compile for CUDA architectures in parallel
export CUDAFLAGS="--threads=4"
cd "$srcdir"/$_name-$pkgver
python -m build --wheel --no-isolation --config-setting=cmake.define.CMAKE_CUDA_ARCHITECTURES="$cuda_archs"
}
check() {
local pytest_options=(
-vv
-W ignore::DeprecationWarning
# distribute tests across multiple CPUs
-n auto
--maxprocesses=8
# do not run CUDA tests
-m 'not cuda'
)
cd $_name-$pkgver
python -m venv --system-site-packages test-env
test-env/bin/python -m installer dist/*.whl
test-env/bin/python -m pytest "${pytest_options[@]}" tests
}
package_python-pytnl() {
optdepends=(
'python-mpi4py: for distributed datastructures (MPI)'
'python-numpy: interoperability with NumPy'
'python-pytnl-cuda: additional CUDA-accelerated modules'
)
cd $_name-$pkgver
python -m installer --destdir="$pkgdir" dist/*.whl
install -vDm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
# fix the _IMPORT_PREFIX variable
sed -i 's|set(_IMPORT_PREFIX "/tmp/.*/wheel/platlib")|set(_IMPORT_PREFIX "/usr")|' "$pkgdir"/usr/lib/cmake/PyTNL/PyTNLTargets.cmake
# split CUDA modules into separate packages
cd "$pkgdir"
local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
_pick $pkgbase-cuda usr/lib/python$python_version/site-packages/pytnl/*cuda*
}
package_python-pytnl-cuda() {
depends+=(
cuda
python-pytnl
)
optdepends=(
'python-cupy: interoperability with CuPy'
)
mv -v $pkgname/* "$pkgdir"
install -vDm 644 $_name-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
|