Re: Use Python "Limited API" in PL/Python

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use Python "Limited API" in PL/Python
Date: 2025-01-07 07:34:39
Message-ID: d5273c95-723f-4d0e-95c1-8edc7acbc008@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

How could one debug this? Is there a way to log into the CI image or
get a directory dump or something like that?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-01-07 08:48:51 per backend WAL statistics
Previous Message Masahiko Sawada 2025-01-07 07:05:06 Re: Conflict detection for update_deleted in logical replication