v2-0003-Activate-Python-Limited-API-in-PL-Python.patch

text/plain

Filename: v2-0003-Activate-Python-Limited-API-in-PL-Python.patch
Type: text/plain
Part: 2
Message: Re: Use Python "Limited API" in PL/Python

Patch

Format: format-patch
Series: patch v2-0003
Subject: Activate Python "Limited API" in PL/Python
File+
src/pl/plpython/plpython.h 9 0
From e059a1653a47f1ca9155a84c8f9a9f122a970ace Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 15 Jan 2025 22:22:59 +0100
Subject: [PATCH v2 3/3] Activate Python "Limited API" in PL/Python

This allows building PL/Python against any Python 3.x version and
using another Python 3.x version at run time.

Discussion: https://www.postgresql.org/message-id/flat/ee410de1-1e0b-4770-b125-eeefd4726a24@eisentraut.org
---
 src/pl/plpython/plpython.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h
index ec822577260..06fc1a5440f 100644
--- a/src/pl/plpython/plpython.h
+++ b/src/pl/plpython/plpython.h
@@ -19,6 +19,15 @@
 #error Python.h must be included via plpython.h
 #endif
 
+/*
+ * 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
  * the system_header pragma therein.
-- 
2.47.1