You are not logged in.

#1 2022-03-27 00:49:27

uroter
Member
Registered: 2021-01-01
Posts: 12

[SOLVED] PKGBUILD help request: python-pnglatex

I'm trying to make a PKGBUILD for this python repo https://github.com/MaT1g3R/pnglatex, which has a setup.py, but I'm having trouble because there is already a pnglatex shell script in the AUR that I also use, and so when building with regular setup.py it tries to install in the pnglatex directory that already belongs to the AUR package. So I'm trying to name the package python-pnglatex, but I still can't figure out where can I correct the build, I tried changing some 'pnglatex' strings in the setup.py for 'python-pnglatex', but I'm still getting errors in the build function.  Some help would be very much appreciated. Here's what I have so far:

pkgname=python-pnglatex
_name=${pkgname#python-}
pkgver=1
pkgrel=1
pkgdesc="A small program that converts LaTeX snippets to png"
arch=("any")
url="https://github.com/MaT1g3R/pnglatex"
license=("GPL3")
depends=(
	"texlive-core"
	"poppler"
	"netpbm"
)
source=("$pkgname::git+$url")
md5sums=('SKIP')

prepare() {
	cd "$srcdir/$pkgname"
	sed -i '30,$s/pnglatex/python-pnglatex/g' "setup.py"
}

build() {
	cd "$srcdir/$pkgname"
	python setup.py build
}

package() {
    cd "$srcdir/$pkgname"
    python setup.py install --prefix=/usr --root="${pkgdir}/" --optimize=1 --skip-build
}

PS: I know the name should probably have -git at the end, but I'm not planning on submitting to the AUR

Edit: I incorrectly put in the comment the url of the shell script pnglatex repo, not the python pnglatex. The PKGBUILD is still broken.

Last edited by uroter (2022-03-27 20:00:02)

Offline

#2 2022-03-27 01:58:35

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] PKGBUILD help request: python-pnglatex

I don't know the answer to your question, but you're going to a lot of effort for something that could be easily replicated with a five line shell script. Whoever wrote that script also seems to be unaware that pdftoppm can export png's directly.

#!/bin/bash
tempdir="$(mktemp -d)" &&
sed -e '1 s/^/\\documentclass{minimal}\\usepackage{amsmath}\\begin{document}/' -e '$ s/$/\\end{document}/' < /dev/stdin | pdflatex --interaction=batchmode --output-directory "$tempdir" &>/dev/null &&
pdfcrop "$tempdir/texput.pdf" &>/dev/null &&
pdftoppm -png -r 600 -singlefile "$tempdir/texput-crop.pdf" "${1%.png}" && rm -rf "$tempdir"

Save that as latex2png.sh and chmod +x latex2png, then, e.g.:

echo '$x^2 + y^2 = z^2$' | latex2png.sh outputname.png

Offline

#3 2022-03-27 04:08:50

uroter
Member
Registered: 2021-01-01
Posts: 12

Re: [SOLVED] PKGBUILD help request: python-pnglatex

Thanks your for answer! Well, I suppose I can uninstall the pnglatex shell script and use your script instead (I had also made some personal shell scripts on top of it, but can rewrite them), but I feel like I'm very close to just renaming the python one that I might as well do that, just need the python building to name the executable 'python-pnglatex' .

Also I know this sort of renaming is possible since I've seen in some Arch packages, like 'perl-rename' vs 'rename'. I'll keep looking in the python documentation and reread the PKGBUILD wiki.

Offline

#4 2022-03-27 14:48:03

yochananmarqos
Member
Registered: 2020-02-05
Posts: 194

Re: [SOLVED] PKGBUILD help request: python-pnglatex

It would be easier to use your own custom PKGBUILD for the pnglatex AUR package and rename the binary then mess around with python-pnglatex.

Here's a proper PKGBUILD for python-pnglatex:

pkgname=python-pnglatex
_name=${pkgname#python-}
pkgver=1.1
pkgrel=1
pkgdesc="A small program that converts LaTeX snippets to png"
arch=('any')
url="https://github.com/MaT1g3R/pnglatex"
license=('GPL3')
depends=('netpbm' 'poppler' 'python' 'texlive-core')
makedepends=('python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz")
sha256sums=('0995060d4926b6d3b40731586c615234c3e45b3142fc15b836601e3b0cf863d3')

build() {
  cd "$_name-$pkgver"
  python setup.py build
}

package() {
  cd "$_name-$pkgver"
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}

Last edited by yochananmarqos (2022-03-27 20:03:15)

Offline

#5 2022-03-27 19:59:33

uroter
Member
Registered: 2021-01-01
Posts: 12

Re: [SOLVED] PKGBUILD help request: python-pnglatex

Thanks your for answer! You're right, changing the other PKGBUILD is easier, I just renamed the executable to 'pnglatex.sh' in its package() function, and now both packages install successfully. Also thanks a lot for your modifications!

I would've like to know how to change the python executable name to python-pnglatex from the PKGBUILD anyways (it shouldn't be too hard I just couldn't find where), if I find it later I'll post it for good measure, but I'll go ahead and mark this as solved.

Offline

Board footer

Powered by FluxBB