summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8873b9dbd51c132efb836a0d02ece5cf97779f55 (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
# Maintainer: Gaute Hope <eg@gaute.vetsj.com>
# Maintainer: Blair Bonnett <blair dot bonnett at gmail dot com>
# Contributor: Rich Li <rich@dranek.com>

pkgname=python-cartopy
pkgver=0.24.1
pkgrel=1
pkgdesc="A cartographic Python library with Matplotlib support for visualisation"
url="https://scitools.org.uk/cartopy/"
depends=(
    'python-matplotlib'
    'python-numpy'
    'python-pillow'
    'python-pyproj'
    'python-pyshp'
    'python-scipy'
    'python-shapely'
)
optdepends=(
    'python-beautifulsoup4: for use with SRTM data'
    'python-fiona: faster shapefile reading'
    'python-gdal: for use with SRTM data'
    'python-owslib: access OGC clients'
    'python-pyepsg: interface to https://epsg.io'
    'python-pykdtree: faster warping of images'
)
makedepends=(
    'cython'
    'python-build'
    'python-installer'
    'python-setuptools'
    'python-setuptools-scm'
    'python-wheel'
)
checkdepends=('python-pytest' 'python-pytest-mpl' 'python-flufl-lock')
license=('BSD-3-Clause')
arch=('x86_64')

_pypi=cartopy
source=(
    "https://files.pythonhosted.org/packages/source/${_pypi::1}/$_pypi/$_pypi-$pkgver.tar.gz"
)
sha256sums=(
    '01c910d5634c69a7efdec46e0a17d473d2328767f001d4dc0b5c4b48e585c8bd'
)

prepare() {
    cd "$_pypi-$pkgver"

    # Remove pre-processed Cython extensions so we can generate a local version.
    rm lib/cartopy/trace.cpp
}

build() {
    cd "$_pypi-$pkgver"
    FORCE_CYTHON=1 python -m build --wheel --no-isolation
}

check() {
    cd "$_pypi-$pkgver"
    python -m venv --system-site-packages test-env
    test-env/bin/python -m installer "dist/Cartopy-$pkgver-"*.whl

    # Run the tests that are included in the wheel. Trying to run the tests in the
    # source directory often seems to import files from the source, rather than from
    # the installed copy, which fails as the compiled modules are not available.
    # The deselected tests fail an image comparison due to small changes in the
    # size and position of text labels.
    cd test-env/lib/python*/site-packages/cartopy/tests
    ../../../../../bin/python -m pytest \
        -k "not test_gridliner and not test_contour_label and not test_annotate" \
        --ignore-glob="*mpl/test_ticks.py"
}

package() {
    cd "$_pypi-$pkgver"
    python -m installer --destdir="$pkgdir" "dist/Cartopy-$pkgver-"*.whl
    install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

    # Remove tests from final package.
    local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
    rm -r "$pkgdir/$site_packages/cartopy/tests"
}