Re: Python Limited API for PL/Python on MSVC - Mailing list pgsql-hackers
| From | Bryan Green |
|---|---|
| Subject | Re: Python Limited API for PL/Python on MSVC |
| Date | |
| Msg-id | eb7b4acb-c187-4fe2-87ba-31c738437b55@gmail.com Whole thread Raw |
| In response to | Python Limited API for PL/Python on MSVC (Bryan Green <dbryan.green@gmail.com>) |
| List | pgsql-hackers |
On 12/30/2025 9:01 AM, Bryan Green wrote: > Ardres, Peter, > > I have submitted a PR > (https://github.com/anarazel/pg-vm-images/pull/131) to pg-vm-images to > fix the python3.lib issue and will submit a patch to re-enable the > Python Limited API on MSVC once done testing. > There are two problems regarding installing and finding python3.lib on Windows (MSVC) builds: 1. We use SimpleInstall=1 as an option in the powershell script that installs python on windows. That is a minimal install and one of the things it does not install...python3.lib. It installs python3XX.lib. 2. Meson will favor the python with the more complete version number. We need to do a bit of work, but not much, in our top-level meson.build for it to find the correct lib. Once we have the python3.lib on our CI images by implementing the first change then the second change can be done. For those who may be interested in trying this locally-- Install python on windows using powershell: (change versions and destination as you see fit) 1. Download: Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.14.0/python-3.14.0-amd64.exe" -OutFile "python-installer.exe" In this step, you could pass SimpleInstall=1 in the ArgumentList and python3.lib would not be installed. 2. Install without SimpleInstall=1: Start-Process -Wait -FilePath "python-installer.exe" -ArgumentList '/quiet', 'InstallAllUsers=1', 'PrependPath=1', 'TargetDir=c:\python\' Then, in your local pg tree you need to remove the guard around Py_LIMITED_API. /* * Enable Python Limited API * * XXX currently not enabled on MSVC because of build failures */ #if !defined(_MSC_VER) #define Py_LIMITED_API 0x03020000 #endif At this point you will get build fails because of the meson issue, so in the top-level meson.build file find the "Library: Python (for 'plpython') line and replace it's code block with the following: ############################################################### # Library: Python (for plpython) ############################################################### pyopt = get_option('plpython') python3_dep = not_found_dep if not pyopt.disabled() pm = import('python') python3_inst = pm.find_installation(python.full_path(), required: pyopt) if python3_inst.found() # For Limited API on MSVC, link against python3.lib instead of python3XX.lib if host_system == 'windows' and cc.get_id() == 'msvc' python3_libdir = python3_inst.get_variable('prefix') / 'libs' python3_lib = cc.find_library('python3', dirs: python3_libdir, required: pyopt) python3_dep = declare_dependency( include_directories: include_directories(python3_inst.get_variable('prefix') / 'include'), dependencies: python3_lib, ) else python3_dep = python3_inst.dependency(embed: true, required: pyopt) endif # Remove this check after we depend on Meson >= 1.1.0 if not cc.check_header('Python.h', dependencies: python3_dep, required: pyopt, include_directories: postgres_inc) python3_dep = not_found_dep endif endif endif Clear your meson cache and reconfigure if needed: meson configure --clearcache build meson setup --reconfigure build Then build and test. -- Bryan Green EDB: https://www.enterprisedb.com
pgsql-hackers by date: