Error on missing Python module in Meson setup
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t46922psql -h localhost -U postgresBuilt from patchset v3 (message #3), July 28, 2026 at 01:43 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t46922_3 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t46922_3 && git checkout t46922_3Patchset v3 (message #3) is on t46922_3
When setting up a postgres tree with Meson on an almost empty Debian 11 VM I
hit an error on "meson setup -Ddebug=true build ." like this:
Program python3 found: YES (/usr/bin/python3)
meson.build:987:2: ERROR: Unknown method "dependency" in object.
The error in itself isn't terribly self-explanatory. According to the log the
error was a missing Python package:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "<string>", line 8, in links_against_libpython
ModuleNotFoundError: No module named ‘distutils.core'
Installing the distutils package fixes it, but it seems harsh to fail setup on
a missing package. Would something like the attached make sense?
--
Daniel Gustafsson https://vmware.com/
Attachments:
meson_python.diffapplication/octet-stream; name=meson_python.diff; x-unix-mode=0644Download+6-2
Hi,
On 2022-11-14 14:23:02 +0100, Daniel Gustafsson wrote:
When setting up a postgres tree with Meson on an almost empty Debian 11 VM I
hit an error on "meson setup -Ddebug=true build ." like this:Program python3 found: YES (/usr/bin/python3)
meson.build:987:2: ERROR: Unknown method "dependency" in object.The error in itself isn't terribly self-explanatory. According to the log the
error was a missing Python package:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "<string>", line 8, in links_against_libpython
ModuleNotFoundError: No module named ‘distutils.core'Installing the distutils package fixes it, but it seems harsh to fail setup on
a missing package. Would something like the attached make sense?
The error is a bit better in newer versions of meson:
meson.build:986: WARNING: <PythonExternalProgram 'python3' -> ['/usr/bin/python3']> is not a valid python or it is missing distutils
but we do still error out weirdly afterwards.
We probably should report this to the meson folks regardless of us working
around it or not.
diff --git a/meson.build b/meson.build index 058382046e..1a7e301fc9 100644 --- a/meson.build +++ b/meson.build @@ -984,8 +984,12 @@ pyopt = get_option('plpython') if not pyopt.disabled() pm = import('python') python3_inst = pm.find_installation(required: pyopt.enabled()) - python3_dep = python3_inst.dependency(embed: true, required: pyopt.enabled()) - if not cc.check_header('Python.h', dependencies: python3_dep, required: pyopt.enabled()) + if python3_inst.found() + python3_dep = python3_inst.dependency(embed: true, required: pyopt.enabled()) + if not cc.check_header('Python.h', dependencies: python3_dep, required: pyopt.enabled()) + python3_dep = not_found_dep + endif + else python3_dep = not_found_dep endif else
Perhaps worth simplifying a bit. What do you think about:
pyopt = get_option('plpython')
python3_dep = not_found_dep
if not pyopt.disabled()
pm = import('python')
python3_inst = pm.find_installation(required: pyopt.enabled())
if python3_inst.found()
python3_dep_int = python3_inst.dependency(embed: true, required: pyopt.enabled())
if cc.check_header('Python.h', dependencies: python3_dep_int, required: pyopt.enabled())
python3_dep = python3_dep
endif
endif
endif
Greetings,
Andres Freund
On 15 Nov 2022, at 01:25, Andres Freund <andres@anarazel.de> wrote:
On 2022-11-14 14:23:02 +0100, Daniel Gustafsson wrote
Installing the distutils package fixes it, but it seems harsh to fail setup on
a missing package. Would something like the attached make sense?The error is a bit better in newer versions of meson:
meson.build:986: WARNING: <PythonExternalProgram 'python3' -> ['/usr/bin/python3']> is not a valid python or it is missing distutils
but we do still error out weirdly afterwards.We probably should report this to the meson folks regardless of us working
around it or not.
Thats better, but I wish meson could be more specific since it at that point
should know if Python works at all or is missing distutils.
Perhaps worth simplifying a bit. What do you think about:
...
Agreed, that's a better version. The attached version with a disabler object
is even more to the point, and seems to works on my box both with and without
distutils and libpython. Is this the correct way to use disablers?
--
Daniel Gustafsson https://vmware.com/