Fix PL/Python build on MSVC with older Meson
authorPeter Eisentraut <peter@eisentraut.org>
Fri, 16 Jan 2026 16:21:32 +0000 (17:21 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Fri, 16 Jan 2026 16:25:05 +0000 (17:25 +0100)
Amendment for commit 2bc60f86219.  With older Meson versions, we need
to specify the Python include directory directly to cc.check_header
instead of relying on the dependency to pass it through.

Author: Bryan Green <dbryan.green@gmail.com>
Discussion: https://www.postgresql.org/message-id/0de98c41-4145-44c1-aac5-087cf5b3e4a9%40gmail.com

meson.build

index eedd40b8137c1c6a685836295dcf2f4243819215..6d304f32fb0a9493c3c43b60ac8db484e4b25120 100644 (file)
@@ -1342,17 +1342,22 @@ if not pyopt.disabled()
     # this internally:
     # <https://github.com/mesonbuild/meson/issues/13824>.
     if host_system == 'windows' and cc.get_id() == 'msvc'
-      python3_libdir = python3_inst.get_variable('prefix') / 'libs'
+      python3_prefix = python3_inst.get_variable('prefix')
+      python3_libdir = python3_prefix / 'libs'
+      python3_incdir = python3_prefix / 'include'
       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'),
+        include_directories: include_directories(python3_incdir),
         dependencies: python3_lib,
       )
+      # Explicit args needed for older Meson compatibility
+      python3_header_check_args = ['/I' + python3_incdir]
     else
       python3_dep = python3_inst.dependency(embed: true, required: pyopt)
+      python3_header_check_args = []
     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)
+    if not cc.check_header('Python.h', args: python3_header_check_args, dependencies: python3_dep, required: pyopt, include_directories: postgres_inc)
       python3_dep = not_found_dep
     endif
   endif