You are not logged in.

#1 Yesterday 00:56:56

traibr
Member
From: United Kingdom
Registered: 2024-01-29
Posts: 34

Install custom python-types-psutil package, safety for Arch-management

Hi all,

I’ve built a small Qtile widget (flameshot-screen-recorder) that requires the type stubs package python-types-psutil, which is not within AUR or pacman repo. Qtile itself works fine without it, but qtile check complains about the missing stub:

error: Library stubs not installed for "psutil"  [import-untyped]
note: Hint: "python3 -m pip install types-psutil"

Because Python externally managed on Arch, trying to install via pip results in:

error: externally-managed-environment
× This environment is externally managed

I want to stick to Arch best practices and avoid using

--break-system-packages

Installing via pipx doesn’t solve the issue either since it puts the package in its own venv.

So I created a PKGBUILD to wrap the PyPI package, building and installing it within a fakeroot environment:

# PKGBUILD snippet
pkgname=python-types-psutil
pkgver=7.0.0.20251001
pkgrel=1
pkgdesc="Type stubs for psutil for use with mypy and other type checkers"
arch=('any')
depends=('python' 'python-psutil')
source=(https://files.pythonhosted.org/packages/.../types_psutil-${pkgver}.tar.gz)
sha256sums=('...')

build() {
    cd "$srcdir/types_psutil-${pkgver}"
    python -m venv venv
    source venv/bin/activate
    pip install --upgrade pip setuptools wheel
    python setup.py bdist_wheel
    deactivate
}

package() {
    cd "$srcdir/types_psutil-${pkgver}"
    python -m venv venv
    source venv/bin/activate
    pip install --prefix="$pkgdir/usr" --root="$pkgdir" .
    deactivate
}

This successfully produced a .pkg.tar.zst.

My question: Will installing this ZST affect Arch’s management of Python in any negative way? Will pacman or repo scans see it as an “unregistered” Python package that could cause issues?

From my understanding, it shouldn’t, but I’d like a second opinion before installing.

Thanks,
Rich

Offline

#2 Yesterday 11:37:10

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,280

Re: Install custom python-types-psutil package, safety for Arch-management

Read https://wiki.archlinux.org/title/Python … guidelines

Moderator Note
Moving to Creating & Modifying Packages subboard


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 Yesterday 13:05:46

traibr
Member
From: United Kingdom
Registered: 2024-01-29
Posts: 34

Re: Install custom python-types-psutil package, safety for Arch-management

@Lone_Wolf

Thank you!

The following has been built under the specified guidelines as per the Arch documentation:

# Python AUR Package
pkgname=python-types-psutil
pkgver=7.0.0.20251001
pkgrel=1
pkgdesc="Type stubs for psutil for use with mypy and other type checkers"
arch=('any')
url="https://pypi.org/project/types-psutil/"
license=('MIT')
depends=('python' 'python-psutil')
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-hatchling')
source=("https://files.pythonhosted.org/packages/9e/91/b020f9100b196a1f247cd12575f68dcdad94f032c1e0c42987d7632142ce/types_psutil-${pkgver}.tar.gz")
sha256sums=('60d696200ddae28677e7d88cdebd6e960294e85adefbaafe0f6e5d0e7b4c1963')

build() {
    cd "types_psutil-${pkgver}"
    python -m build --wheel --no-isolation
}

package() {
    cd "types_psutil-${pkgver}"
    python -m installer --destdir="$pkgdir" dist/*.whl
}

Package installed successfully & Qtile is now happy.

Please consider the request closed.

Last edited by traibr (Yesterday 13:45:30)

Offline

#4 Today 08:52:48

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 14,280

Re: Install custom python-types-psutil package, safety for Arch-management

Building in a clean chroot fails .

* Getting build dependencies for wheel...

Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/pyproject_hooks/_impl.py", line 402, in _call_hook
    raise BackendUnavailable(
    ...<4 lines>...
    )
pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'

ERROR Backend 'setuptools.build_meta' is not available.
==> ERROR: A failure occurred in build().
    Aborting...

you probably need to add python-setuptools as makedepend, see https://wiki.archlinux.org/title/Python … _distutils for details.

Last edited by Lone_Wolf (Today 08:53:27)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB