summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6e246b6cfe18f90f657d63ed0ee7c8dd7c76e3a3 (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
# Maintainer: Renato Caldas <renato@calgera.com>
# Maintainer: Carlos Aznarán <caznaranl@uni.pe>
pkgname=('dolfinx-git' 'python-fenics-dolfinx-git')
pkgdesc='Next generation FEniCS problem solving environment'
pkgver=0.7.0.dev0_r27527.200e94c
pkgrel=1
arch=('x86_64')
url='https://fenicsproject.org'
license=('MIT')
depends=('basix-git' 'boost-libs' 'petsc' 'pugixml' 'hdf5-openmpi' 'adios2' 'scotch'
         'python-fenics-ufl-git' 'python-fenics-basix-git')
makedepends=('git' 'cmake' 'python-build' 'python-installer' 'python-wheel' 'python-setuptools'
             'pybind11' 'chrpath' 'python-fenics-ffcx-git' 'python-mpi4py')
optdepends=('slepc: for use SLEPc eigen solver'
            'parmetis: for compute graph partition'
            'kahip: for compute graph partition')
source=('git+https://github.com/FEniCS/dolfinx')
sha512sums=('SKIP')

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

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

build() {
    cd "$srcdir/dolfinx"
    source /etc/profile.d/petsc.sh

    # Build c++ library
    cmake -DCMAKE_BUILD_TYPE="Release" \
        -S cpp \
        -B build \
        -DBUILD_SHARED_LIBS=TRUE \
        -DCMAKE_CXX_STANDARD=20 \
        -DCMAKE_C_COMPILER=gcc \
        -DCMAKE_CXX_COMPILER=g++ \
        -DDOLFINX_ENABLE_KAHIP=ON \
        -DDOLFINX_ENABLE_PARMETIS=ON \
        -DDOLFINX_ENABLE_SCOTCH=ON \
        -DDOLFINX_ENABLE_SLEPC=ON \
        -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 bindings
    export CMAKE_PREFIX_PATH="$srcdir/tmp/usr"
    cd "$srcdir/dolfinx/python"
    python -m build --wheel --no-isolation "$srcdir/dolfinx/python"
}

package_dolfinx-git() {
    provides=('dolfinx')
    conflicts=('dolfinx')

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

    # Remove insecure runpath
    chrpath --delete "$pkgdir/usr/lib/libdolfinx.so"
}

package_python-fenics-dolfinx-git() {
    provides=('python-fenics-dolfinx')
    conflicts=('python-fenics-dolfinx')
    depends=('dolfinx-git' 'python-fenics-ffcx-git' 'python-fenics-basix-git' 'python-mpi4py')
    optdepends=('gmsh: for handling gmsh meshes'
                'python-scipy: for sparse matrices')

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

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