You are not logged in.

#1 2022-03-11 23:43:38

jshogoth
Member
Registered: 2022-01-12
Posts: 6

Utilizing a python venv in a PKGBUILD

I'm trying to create a PKGBUILD for building static variants of cantarell-fonts, since they are no longer provided by upstream as prebuilt artifacts. Building those needs some exotic python packages, mostly found in the AUR.
However, instead of declaring lots of AUR python packages as makedepends I could also create a venv during the build and install the packages with pip. The resulting PKGBUILD looks like this:

pkgname=cantarell-static-fonts
_pkgname=cantarell-fonts
pkgver=0.303.1
pkgrel=1
pkgdesc="Humanist sans serif font"
url="https://gitlab.gnome.org/GNOME/cantarell-fonts"
arch=(any)
provides=(cantarell-fonts)
conflicts=(cantarell-fonts)
license=(custom:SIL)
makedepends=(meson appstream-glib python)
source=("https://download.gnome.org/sources/${_pkgname}/${pkgver:0:5}/${_pkgname}-$pkgver.tar.xz"
        "only_remove_overlaps_with_pathops_if_available.patch"
        "do_not_require_pathops.patch"
        "bump_cu2qu.patch")
sha256sums=('f9463a0659c63e57e381fdd753cf1929225395c5b49135989424761830530411'
            '5ebb937d0583773ec383537db8f5d3891f9c8fb7d1b5a9d8f1d16219e17858c8'
            '037a9ee76801b3b401f5afe592b10c37eb0407e8a8245df8831d001d9f2fdfb9'
            '6bef6ec695177082881dc1ef2c95013f0f294c237e38e4e6b3eacfe52363dcbf')

prepare() {
  cd "$_pkgname-$pkgver"
  patch --forward --strip=1 --input="${srcdir}/only_remove_overlaps_with_pathops_if_available.patch"
  patch --forward --strip=1 --input="${srcdir}/do_not_require_pathops.patch"
  patch --forward --strip=1 --input="${srcdir}/bump_cu2qu.patch"
  
}  
build() {
  python -m venv venv
  source venv/bin/activate
  pip install -r $_pkgname-$pkgver/requirements.txt
  arch-meson $_pkgname-$pkgver build -D buildstatics=true -D buildvf=false
  meson compile -C build
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 $_pkgname-$pkgver/COPYING
}

I never came across PKGBUILDs using a venv to build something. The PKGBUILD works perfectly and you don't have to inspect and build every dependency from the AUR. Is this approach viable? I'm wondering if I'm overlooking something...

Offline

#2 2022-03-12 12:42:33

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,911

Re: Utilizing a python venv in a PKGBUILD

NOTE: I have no idea if makepkg process supports venv in PKGBUILD , assuming it does :


Using this method causes the pkgbuild to download things that are not under makepkg control.

It reminds me of git submodules , https://wiki.archlinux.org/title/VCS_pa … submodules .

Maybe you can use a similar method to get the urls for the python stuff in the sources array ?

That way makepkg will take care of downloading, checksum verification, signature checking etc and pip can focus on installing.


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


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB