diff --git a/meson.build b/meson.build index 555c94796c6..d8a701440da 100644 --- a/meson.build +++ b/meson.build @@ -1336,7 +1336,21 @@ if not pyopt.disabled() pm = import('python') python3_inst = pm.find_installation(python.full_path(), required: pyopt) if python3_inst.found() - python3_dep = python3_inst.dependency(embed: true, required: pyopt) + # On MSVC, link against python3.lib instead of python3XX.lib for + # Python Limited API. Right now, this is the only platform that + # needs this workaround. In the long run, Meson should handle + # this internally: + # . + 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 diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h index d0745bb68af..595e4af7491 100644 --- a/src/pl/plpython/plpython.h +++ b/src/pl/plpython/plpython.h @@ -25,12 +25,8 @@ /* * Enable Python Limited API - * - * XXX currently not enabled on MSVC because of build failures */ -#if !defined(_MSC_VER) #define Py_LIMITED_API 0x03020000 -#endif /* * Pull in Python headers via a wrapper header, to control the scope of