summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7ffc7ddeb71977e336970dc4061da561248df3b8 (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
# Maintainer: Iyán Méndez Veiga <me (at) iyanmv (dot) com>
# Contributor: Sergio Davies <newsletter dot sergio at gmail dot com>
_name=quantities
pkgname=python-$_name
pkgver=0.16.4
pkgrel=1
pkgdesc="Support for physical quantities with units, based on NumPy"
arch=(any)
url=https://github.com/python-quantities/python-quantities
license=(BSD-3-Clause)
depends=(python-numpy)
makedepends=(
    git
    python-build
    python-installer
    python-setuptools
    python-setuptools-scm
    python-wheel
)
optdepends=("python-scipy: integrate using SciPy's trapezoid implementation")
checkdepends=(python-pytest)
source=(
    $_name::git+https://github.com/python-quantities/python-quantities#tag=v$pkgver
    fix-tests.patch
)
b2sums=('10d9724e7128e7c01e7b7537908f2f1595112ab7a5e9745b30249107d6eff4cbf32a65c04278aa963f528e1f0f9e4580c71912ed6dda8a44b09ea4877f126fdf'
        'dba5b5a95edb249d8d430500724e34eafe4a87a935eb6147c019797c437bba38bcbf3ffd6ca131cebec03e09674579add64d6ed63383308ce341049bb688ff70')

prepare() {
    # Modify imports to test from the installed wheel package
    patch -Np1 -d $_name < fix-tests.patch
}

build() {
    cd $_name
    python -m build --wheel --no-isolation
}

check() {
    cd $_name
    local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
    python -m installer --destdir=../test_dir dist/*.whl
    mv $_name/tests .
    rm -rf $_name
    PYTHONPATH="$PWD/../test_dir/usr/lib/python$python_version/site-packages" pytest tests
}

package() {
    cd $_name
    python -m installer --destdir="$pkgdir" dist/*.whl
    # Remove tests
    local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
    rm -rf "$pkgdir"/usr/lib/python$python_version/site-packages/quantities/tests
    install -Dm644 doc/user/license.rst "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}