summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: aa5b972e8006f5cea60411154a04764273314e3e (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
# Maintainer: Renato Caldas <renato@calgera.com>
# Maintainer: Carlos Aznarán <caznaranl@uni.pe>
pkgname=(basix-git python-fenics-basix-git)
pkgdesc="FEniCSx finite element basis evaluation library"
pkgver="0.9.0.dev0_r1041.8818981"
pkgrel=1
arch=(x86_64)
url="https://github.com/FEniCS/basix"
license=(MIT)
makedepends=(cmake python-build python-installer python-wheel
    python-setuptools nanobind python-scikit-build-core chrpath git)
conflicts=(basix fenics-basix-git python-fenics-basix python-basix-git)
source=('git+https://github.com/FEniCS/basix')
sha512sums=('SKIP')

pkgver() {
    cd "$srcdir/basix"
    # The main repo unfortunately has no meaningful tags..
    printf "%s_r%s.%s" "$(sed -n -e 's/^version *= \"*\(.*\)\"/\1/p' pyproject.toml)" \
        "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
    git -C "${srcdir}/basix" clean -dfx
}

build() {
    cd "$srcdir/basix"

    # Build c++ library
    cmake -DCMAKE_BUILD_TYPE="Release" \
        -S cpp \
        -B build \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -Wno-dev
    cmake --build build

    # HACK: Install to temporary dir, required for building the wheel
    export DESTDIR="$srcdir/tmp"
    cmake --install build

    # Build the python wheel
    export CMAKE_PREFIX_PATH="$srcdir/tmp/usr"
    python -m build --wheel --no-isolation "$srcdir/basix/python"
}

package_basix-git() {
    depends=(blas lapack)

    cd "$srcdir/basix"
    DESTDIR="$pkgdir" cmake --install build
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/basix-git/LICENSE"
}

package_python-fenics-basix-git() {
    depends=(basix-git python-fenics-ufl-git python-numpy)
    optdepends=('python-numba: for Numba helper function support')

    cd "$srcdir/basix/python"
    python -m installer --destdir="$pkgdir" dist/*.whl
    find "$pkgdir" -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
    install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/python-fenics-basix-git/LICENSE"

    # Remove insecure runpath
    find "$pkgdir" -iname "_basixcpp*so" | xargs chrpath --delete
}