pgsql: Enable Python Limited API for PL/Python on MSVC
Enable Python Limited API for PL/Python on MSVC
Previously, the Python Limited API was disabled on MSVC due to build
failures caused by Meson not knowing to link against python3.lib
instead of python3XX.lib when using the Limited API.
This commit works around the Meson limitation by explicitly finding
and linking against python3.lib on MSVC, and removes the preprocessor
guard that was disabling the Limited API on MSVC in plpython.h.
This requires python3.lib to be present in the Python installation,
which is included when Python is installed.
Author: Bryan Green <dbryan.green@gmail.com>
Discussion: /messages/by-id/ee410de1-1e0b-4770-b125-eeefd4726a24@eisentraut.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2bc60f86219b00a9ba23efab8f4bb8de21e64e2a
Modified Files
--------------
meson.build | 16 +++++++++++++++-
src/pl/plpython/plpython.h | 4 ----
2 files changed, 15 insertions(+), 5 deletions(-)
This is failing on buildfarm member drongo:
<https://buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=drongo&br=master>.
AFAICT, this is the only buildfarm member that tests Python on
Windows, so we have no additional results to compare with. It did pass
on Cirrus CI. Andrew/Bryan, could you figure out how the Python
installation on drongo is different?
Show quoted text
On 14.01.26 10:53, Peter Eisentraut wrote:
Enable Python Limited API for PL/Python on MSVC
Previously, the Python Limited API was disabled on MSVC due to build
failures caused by Meson not knowing to link against python3.lib
instead of python3XX.lib when using the Limited API.This commit works around the Meson limitation by explicitly finding
and linking against python3.lib on MSVC, and removes the preprocessor
guard that was disabling the Limited API on MSVC in plpython.h.This requires python3.lib to be present in the Python installation,
which is included when Python is installed.Author: Bryan Green <dbryan.green@gmail.com>
Discussion: /messages/by-id/ee410de1-1e0b-4770-b125-eeefd4726a24@eisentraut.orgBranch
------
masterDetails
-------
https://git.postgresql.org/pg/commitdiff/2bc60f86219b00a9ba23efab8f4bb8de21e64e2aModified Files
--------------
meson.build | 16 +++++++++++++++-
src/pl/plpython/plpython.h | 4 ----
2 files changed, 15 insertions(+), 5 deletions(-)
On 1/15/2026 3:36 AM, Peter Eisentraut wrote:
This is failing on buildfarm member drongo: <https://
buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=drongo&br=master>.
AFAICT, this is the only buildfarm member that tests Python on Windows,
so we have no additional results to compare with. It did pass on Cirrus
CI. Andrew/Bryan, could you figure out how the Python installation on
drongo is different?
Peter, Andrew,
The failure on drongo is due to my writing this patch to support meson
versions >= 1.1.0. I setup my local environment to match CI and was
using meson 1.10.0. Before 1.1.0 you needed to pass the include
directory to check_headers with arg:. I have made the changes and
tested python 3.11 w/meson 0.57.2 and 1.0.1. I have also retested with
python 3.14 and meson 1.10.0. Everything passed.
Additional items to note:
1. meson 1.0.1 expects distutils which was retired in python 3.12. If
you want to use a later python with that version of meson (or earlier)
you will need to install setuptools which has a distutils shim I am led
to believe.
2. when building with meson 0.57.2 I had to provide -Dreadline=disabled
for the build to succeed.
The v2 patch is attached.
--
Bryan Green
EDB: https://www.enterprisedb.com
Attachments:
v2-0001-Enable-Python-Limited-API-for-PL-Python-on-MSVC.patchtext/plain; charset=UTF-8; name=v2-0001-Enable-Python-Limited-API-for-PL-Python-on-MSVC.patchDownload+19-7
On 15.01.26 17:21, Bryan Green wrote:
On 1/15/2026 3:36 AM, Peter Eisentraut wrote:
This is failing on buildfarm member drongo: <https://
buildfarm.postgresql.org/cgi-bin/show_history.pl?nm=drongo&br=master>.
AFAICT, this is the only buildfarm member that tests Python on Windows,
so we have no additional results to compare with. It did pass on Cirrus
CI. Andrew/Bryan, could you figure out how the Python installation on
drongo is different?Peter, Andrew,
The failure on drongo is due to my writing this patch to support meson
versions >= 1.1.0. I setup my local environment to match CI and was
using meson 1.10.0. Before 1.1.0 you needed to pass the include
directory to check_headers with arg:. I have made the changes and
tested python 3.11 w/meson 0.57.2 and 1.0.1. I have also retested with
python 3.14 and meson 1.10.0. Everything passed.
Thanks, this has been committed and seems to have fixed the drongo failure.