summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 32d83dc09c8db62b25b7fd791e3922323b10bfd7 (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: Claudia Pellegrino <aur ät cpellegrino.de>
# Contributor: Marcin Kornat <rarvolt@gmail.com>
pkgname=labelle
pkgver=1.4.3
pkgrel=1
pkgdesc="Linux Software to print with LabelManager PnP from Dymo"
arch=('any')
license=('Apache-2.0')
replaces=('dymoprint')
url="https://github.com/labelle-org/labelle"
depends=(
    'python'
    'python-barcode'
    'python-darkdetect'
    'python-pillow'
    'python-platformdirs'
    'python-pyqrcode'
    'python-pyqt6'
    'python-pyusb'
    'python-rich'
    'python-typer'
)
makedepends=(
    'git'
    'python-build'
    'python-hatch-fancy-pypi-readme'
    'python-hatch-vcs'
    'python-hatchling'
    'python-installer'
    'python-pip'
    'python-setuptools'
    'python-setuptools-scm'
)
checkdepends=(
    'python-pytest'
    'python-pytest-image-diff'
    'python-pytest-qt'
)
source=(
        "${pkgname}-${pkgver}.tar.gz::https://github.com/labelle-org/labelle/archive/v${pkgver}.tar.gz"
        "91-dymo-labelmanager-pnp.rules"
        "dymo-labelmanager-pnp.conf"
)
sha512sums=('9f1370e5c9667eda7bb92c97ab52d622ac05e7383b499206ea3e4cbe8ae2f6e00626ee21f9093cd54c4d56c40ebd8219c90f99f16f812e5ad2509e6a0698d3a0'
            '3768fdfc8345d909cac837fc6582c3f064695a211c9150f6dd2e3a2b846c4265efd5ac24c629c68dfa6ac7421604c448d47e4fb0966a68773107502cc7f6f183'
            '1cd7294374617035e0f3614f2a2914647879fa58cf3da0d7c5705697e30961161cb21e10b45fa2bd417c5487b585cc7bdfec1ee863fa73a3f47ddd553702fe8d')

prepare() {
    cd "${pkgname}-${pkgver}"

    # Unpin dependency range
    sed -i -E -e 's/"(hatchling|hatch-vcs) [^"]+"/"\1"/g' pyproject.toml
}

build() {
    cd "${pkgname}-${pkgver}"
    export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"
    python -m build --wheel --no-isolation
}

check() {
    cd "${pkgname}-${pkgver}"
    local _site_packages
    _site_packages="$(python -c 'import site; print(site.getsitepackages()[0])')"
    python -m installer --destdir=tmp_install dist/*.whl

    echo >&2 'Running unit tests'
    # The `test_main_window` test passes just fine in a clean chroot
    # or on systems with no label printer attached.
    # However, in practice, many users build their packages on
    # machines with printers attached, which fails the assertion,
    # so the test causes more hassle in the long run than it’s worth.
    PYTHONPATH="${PWD}/tmp_install/${_site_packages}" \
        pytest src -k 'not test_main_window'
}

package() {
    install -Dm644 91-dymo-labelmanager-pnp.rules "${pkgdir}/etc/udev/rules.d/91-dymo-labelmanager-pnp.rules"
    install -Dm644 dymo-labelmanager-pnp.conf "${pkgdir}/etc/usb_modeswitch.d/dymo-labelmanager-pnp.conf"

    cd "${pkgname}-${pkgver}"
    python -m installer --destdir="${pkgdir}" dist/*.whl
}