Python installation selection in Meson

Started by Peter Eisentrautabout 2 years ago5 messages
#1Peter Eisentraut
peter@eisentraut.org
1 attachment(s)

I noticed that under meson, the selection of the Python installation
using the 'PYTHON' option doesn't work completely. The 'PYTHON' option
determined the Python binary that will be used to call the various build
support programs. But it doesn't affect the Python installation used
for PL/Python. For that, we need to pass the program determined by the
'PYTHON' option back into the find_installation() routine of the python
module. (Otherwise, find_installation() will just search for an
installation on its own.) See attached patch. I ran this through
Cirrus, seems to work.

Attachments:

0001-Meson-python-detection.patchtext/plain; charset=UTF-8; name=0001-Meson-python-detection.patchDownload
From d83c43c1bed2a096549fada42951b346b269c551 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 28 Nov 2023 18:56:18 +0100
Subject: [PATCH] Meson python detection

When we look for the Python installation using the meson python
module, we should make it use the python program previously determined
by the 'PYTHON' option.  Otherwise, it will just use its own search
and the 'PYTHON' option won't affect it.
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index ee58ee7a06..24fddc677b 100644
--- a/meson.build
+++ b/meson.build
@@ -1063,7 +1063,7 @@ pyopt = get_option('plpython')
 python3_dep = not_found_dep
 if not pyopt.disabled()
   pm = import('python')
-  python3_inst = pm.find_installation(required: pyopt)
+  python3_inst = pm.find_installation(python.path(), required: pyopt)
   if python3_inst.found()
     python3_dep = python3_inst.dependency(embed: true, required: pyopt)
     # Remove this check after we depend on Meson >= 1.1.0
-- 
2.43.0

#2Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#1)
Re: Python installation selection in Meson

Hi,

On 2023-11-28 19:02:42 +0100, Peter Eisentraut wrote:

I noticed that under meson, the selection of the Python installation using
the 'PYTHON' option doesn't work completely. The 'PYTHON' option determined
the Python binary that will be used to call the various build support
programs. But it doesn't affect the Python installation used for PL/Python.
For that, we need to pass the program determined by the 'PYTHON' option back
into the find_installation() routine of the python module. (Otherwise,
find_installation() will just search for an installation on its own.) See
attached patch. I ran this through Cirrus, seems to work.

Makes sense!

Greetings,

Andres Freund

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Peter Eisentraut (#1)
Re: Python installation selection in Meson

On 2023-11-28 Tu 13:02, Peter Eisentraut wrote:

I noticed that under meson, the selection of the Python installation
using the 'PYTHON' option doesn't work completely.  The 'PYTHON'
option determined the Python binary that will be used to call the
various build support programs.  But it doesn't affect the Python
installation used for PL/Python.  For that, we need to pass the
program determined by the 'PYTHON' option back into the
find_installation() routine of the python module.  (Otherwise,
find_installation() will just search for an installation on its own.) 
See attached patch.  I ran this through Cirrus, seems to work.

I noticed when working on the meson/windows stuff that meson would try
to build plpython against its python installation, which failed
miserably. The workaround was to abandon separate meson/ninja
installations via chocolatey, and instead install them using pip. Maybe
this was as a result of the above problem?

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#4Peter Eisentraut
peter@eisentraut.org
In reply to: Andrew Dunstan (#3)
Re: Python installation selection in Meson

On 29.11.23 14:23, Andrew Dunstan wrote:

On 2023-11-28 Tu 13:02, Peter Eisentraut wrote:

I noticed that under meson, the selection of the Python installation
using the 'PYTHON' option doesn't work completely.  The 'PYTHON'
option determined the Python binary that will be used to call the
various build support programs.  But it doesn't affect the Python
installation used for PL/Python.  For that, we need to pass the
program determined by the 'PYTHON' option back into the
find_installation() routine of the python module.  (Otherwise,
find_installation() will just search for an installation on its own.)
See attached patch.  I ran this through Cirrus, seems to work.

I noticed when working on the meson/windows stuff that meson would try
to build plpython against its python installation, which failed
miserably. The workaround was to abandon separate meson/ninja
installations via chocolatey, and instead install them using pip. Maybe
this was as a result of the above problem?

That sounds like it could be the case.

#5Peter Eisentraut
peter@eisentraut.org
In reply to: Andres Freund (#2)
Re: Python installation selection in Meson

On 28.11.23 19:16, Andres Freund wrote:

On 2023-11-28 19:02:42 +0100, Peter Eisentraut wrote:

I noticed that under meson, the selection of the Python installation using
the 'PYTHON' option doesn't work completely. The 'PYTHON' option determined
the Python binary that will be used to call the various build support
programs. But it doesn't affect the Python installation used for PL/Python.
For that, we need to pass the program determined by the 'PYTHON' option back
into the find_installation() routine of the python module. (Otherwise,
find_installation() will just search for an installation on its own.) See
attached patch. I ran this through Cirrus, seems to work.

Makes sense!

I have committed this, and also backpatched to 16 to keep the behavior
consistent.