Installing pyproject.toml using Python packages globally in Arch Linux

Today, I have tried to install the indieweb-utils on my computer.

Since I eventually want to use it for a couple of ideas for my blog, I wanted a global installation. My blog is currently depending on the local installation of the Nikola, and I did not want create the dedicated environment just for this. It is not a problem, that would bother me yet.

But I also did not want to install it directly with pip, mostly because I want a simplified way to deal with program installations. Namely have them all installed in one way, so that when I am looking at installed packages, I only need to look in one place. So the default package manager it is for me.

But the automatically generated PKGBULD files for python assume the installation with the setup files. But both the indieweb-utils and some of the dependencies, like flit_core package use the pyproject.toml file instead of the setup.py.

This also meant, that my previous knowledge was also not that helpful.

Thankfully, the Arch Linux have an excellent documentation, and I eventually find a mostly solution to my problems there. The below file is the one, that I ended up using.

Below is the PKGBUILD, that eventually worked, just so that next time I do not have to deal with figuring out it again.

pkgbase='python-indieweb-utils'
pkgname=('python-indieweb-utils')
_module='indieweb_utils'
pkgver='0.2.0'
pkgrel=1
pkgdesc="IndieWeb Utils Library"
url=""
depends=('python')
makedepends=('python-build python-mf2py python-flit_core')
license=('unknown')
arch=('any')
source=("indiewebutils::git+https://github.com/capjamesg/indieweb-utils")
sha256sums=('SKIP')

build() {
    cd indiewebutils
    python -m build --wheel --no-isolation
}

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

Some of the things, that I have figured out with this. The part in front of the :: in the source is the name of the folder, where the things get saved. This name can then be used in the build and package parts.

And the git+ in front is sometimes necessary, otherwise it saves the HTML of the GitHub page.

I also needed to comment the check for summary in the common.py file in the flit package. Some of the files (the first I got the error was init.py) do not have the doctrine strings, or they are unrecognizable by it, so the package would not build.

So I changed the part around the line 210 in the following way. Before the code looked like this:

if want_summary:
    if (not docstring) or not docstring.strip():
        raise NoDocstringError(
            'Flit cannot package module without docstring, or empty docstring. '
            'Please add a docstring to your module ({}).'.format(target.file)
        )
    res['summary'] = docstring.lstrip().splitlines()[0]

After the change the code looked like this:

if want_summary:
    if (not docstring) or not docstring.strip():
        res['summary'] = ""
    else:
        res['summary'] = docstring.lstrip().splitlines()[0]

Maybe I should instead figure out, where I could be adding the docstrings, but I am not in the mode right now. Maybe in some other time. Would be one of my first contributions to the open source, started by another person.

Well, the library seems to work, since I could use the check_post_type function and it worked. So now I can start using it in my code.