summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 08dd256a3393a1308945c0687bff56649530121d (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
# Maintainer: Astro Benzene <universebenzene at sina dot com>

pkgbase=python-pvextractor
_pyname=${pkgbase#python-}
pkgname=("python-${_pyname}" "python-${_pyname}-doc")
pkgver=0.4
pkgrel=1
pkgdesc="Position-velocity diagram extractor"
arch=('any')
url="https://pvextractor.readthedocs.io"
license=('BSD')
makedepends=('python-setuptools-scm'
             'python-wheel'
             'python-build'
             'python-installer'
             'python-sphinx-astropy'
             'python-astropy'
             'python-scipy')
checkdepends=('python-pytest-astropy-header'
              'python-pytest-doctestplus'
              'python-matplotlib'
              'python-spectral-cube'
              'python-pyqt6')
#             'python-pyqt5') # scipy <- radio-beam
source=("https://files.pythonhosted.org/packages/source/${_pyname:0:1}/${_pyname}/${_pyname}-${pkgver}.tar.gz"
        'fix-doc-build-warning.patch')
md5sums=('005cce9ff817ac777f7e3e751797130d'
         'ee80bc266d21f35c07a59361254517dd')

prepare() {
    cd ${srcdir}/${_pyname}-${pkgver}

    sed -i '/a-z/s|"^|r"^|' ${_pyname}/pvregions.py
#   sed -i -e '/PyQt6/d' -e 's/QtAgg/Qt5Agg/g' ${_pyname}/tests/test_gui.py
    sed -i -e "/version =/c version = '${pkgver}'" -e "/release =/c release = '${pkgver}'" docs/conf.py
    patch -Np1 -i "${srcdir}/fix-doc-build-warning.patch"
#   sed -i "/----/s/-/~/g" programmatic.rst
#   sed -i "/ds9.rst/a\   plotting.rst" index.rst
}

build() {
    cd ${srcdir}/${_pyname}-${pkgver}
    python -m build --wheel --no-isolation

    msg "Building Docs"
    PYTHONPATH="../build/lib" make -C docs html
}

check() {
    cd ${srcdir}/${_pyname}-${pkgver}

    pytest || warning "Tests failed" # -vv -l -ra --color=yes -o console_output_style=count
}

package_python-pvextractor() {
    depends=('python>=3.8'
             'python-matplotlib>=3.5'
             'python-scipy>=1.8'
             'python-qtpy>=2.0'
             'python-spectral-cube>=0.4')
    optdepends=('python-pvextractor-doc: Documentation for pvextractor')
    cd ${srcdir}/${_pyname}-${pkgver}

    install -D -m644 -t "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
    install -D -m644 -t "${pkgdir}/usr/share/doc/${pkgname}" README.rst
    python -m installer --destdir="${pkgdir}" dist/*.whl
}

package_python-pvextractor-doc() {
    pkgdesc="Documentation for Python pvextractor module"
    cd ${srcdir}/${_pyname}-${pkgver}/docs/_build

    install -D -m644 -t "${pkgdir}/usr/share/licenses/${pkgname}" ../../LICENSE
    install -d -m755 "${pkgdir}/usr/share/doc/${pkgbase}"
    cp -a html "${pkgdir}/usr/share/doc/${pkgbase}"
}