With PEP 517 it is possible to declare a build system for your project. This has lead to the development of new build systems that pip can now utilize to perform builds. They typically are terrible when it comes to extension modules. Should we recommend meson as build system for those cases and perhaps in general?
The existing systems have various issues. Setuptools
setup.py often has a lot of imperative code and carries a lot of historical baggage. Flit is generally great for pure Python projects, but you can’t use it with extension modules. I can’t say much about Poetry as a build-system, but as far as I can tell it does not support extension modules either, and it’s a pain to bootstrap considering the amount of dependencies it has.
Some years ago the Meson build system was released. It’s typically used for projects where one may otherwise use cmake. Behind the scenes, it uses Ninja to perform the actual build. Compared to other build systems Meson is very pleasant to use. The syntax looks like Python and as a build system it contains already the routines you want for finding dependencies.
Obviously there is already support for building against Python. Furthermore, it’s great for cross-compilation.
In Nixpkgs we’ve noticed that an increasing amount of packages are switching to Meson, most notably Gnome and there is also a push from a part of the community to use it for the actual package manager so we could support Windows. I saw there is a package that allows one to use Meson as a PEP517 build system and the author opened a PR for
pygobject to adopt it.
Meson is implemented in Python and wheels are available for it on PyPI. Also, wheels are available for the dependency Ninja for Linux/MacOSX/Windows. For an example of a project, I suggest looking at the source of the Python package providing support for Meson.
I realized I should have mentioned Bazel as well. This build system is getting an increasing amount of traction. It is a far more complex system though and a heavy dependency so unless you really need it (say you have a project like tensorflow), we should not bother with it.