From: | Jakob Egger <jakob(at)eggerapps(dot)at> |
---|---|
To: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Use Python "Limited API" in PL/Python |
Date: | 2025-01-14 15:51:05 |
Message-ID: | F2D46DDC-2C18-4F08-ACBB-EBA20F3D5888@eggerapps.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 07.01.2025, at 08:34, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> On 02.12.24 09:51, Peter Eisentraut wrote:
>> This patch changes PL/Python to use the Python "limited API". This API has stronger ABI stability guarantees.[0] This means, you can build PL/ Python against any Python 3.x version and use any other Python 3.x version at run time.
>> This is especially useful for binary packages where the operating system does not come with a fixed suitable version of Python. For example, Postgres.app (for macOS) would prefer to link against the Python version supplied by python.org (Python.app). But that has a 3.x version that changes over time. So instead they bundle a Python version inside Postgres.app. The Windows installer used to also bundle Python but as of PG17 you have to get it yourself, but you have to get a very specific version [1], which is unsatisfactory. This patch fixes that: You can use any Python version independent of what PL/Python was built against. (There is a mechanism to say "at least 3.N", but for this patch, we don't need that, we can stick with the current minimum of 3.2.)
>> (I have only tested the macOS side of this, not the Windows side. In fact, the patch currently doesn't build on Windows on CI. I haven't figured out why.)
>
> A bit more exploration of that Windows build failure:
>
> This patch changes it so that, on Windows, plpython is linked against a library called "python3.lib" instead of previously "python311.lib" or similar. The build failure is [0]
>
> LINK : fatal error LNK1104: cannot open file 'python3.lib'
>
> [0]: https://cirrus-ci.com/task/5738515637469184
>
> which suggests that the file isn't there. But we have tested this internally and the build succeeded locally. I also don't see anything in the Python installer code or documentation that suggests that there is an option not to install that file or something like that. It should be installed right next to the python3XX.lib file.
I think the problem is that meson doesn't know we want to use the limited API.
I found this related issue on Github: https://github.com/mesonbuild/meson/issues/13824
Someone suggests to change the Python dependency in the meson.build file like this:
py_dep = declare_dependency(
dependencies: py_dep,
compile_args: '-DPy_LIMITED_API='0x030100',
)
I've tried to create a patch with this change. I'm attaching it to this message so that cfbot picks it up. (I was unable to reproduce the issue locally)
Best regards,
Jakob

From | Date | Subject | |
---|---|---|---|
Next Message | Sami Imseih | 2025-01-14 15:59:52 | Re: question about executor hooks |
Previous Message | Aleksander Alekseev | 2025-01-14 15:18:56 | Re: Coccinelle for PostgreSQL development [1/N]: coccicheck.py |