https://src.fedoraproject.org/rpms/blender/raw/7045717eb5477c40905f6d29dfd3dbf5ed674e4d/f/blender-3.6.1-py312-pylongobject.patch

--- a/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_IntegrationType.cpp
@@ -188,6 +188,7 @@ PyTypeObject IntegrationType_Type = {
 
 /*-----------------------BPy_IntegrationType instance definitions -------------------------*/
 
+#if PY_VERSION_HEX < 0x030c0000 /* older than Python 3.12 */
 static PyLongObject _IntegrationType_MEAN = {
     PyVarObject_HEAD_INIT(&IntegrationType_Type, 1){MEAN}};
 static PyLongObject _IntegrationType_MIN = {PyVarObject_HEAD_INIT(&IntegrationType_Type, 1){MIN}};
@@ -196,6 +197,26 @@ static PyLongObject _IntegrationType_FIR
     PyVarObject_HEAD_INIT(&IntegrationType_Type, 1){FIRST}};
 static PyLongObject _IntegrationType_LAST = {
     PyVarObject_HEAD_INIT(&IntegrationType_Type, 1){LAST}};
+#else
+#define NON_SIZE_BITS 3
+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
+#define _Py_IntegrationTypeType_DIGIT_INIT(val) \
+    { \
+        .ob_base = PyObject_HEAD_INIT(&IntegrationType_Type) \
+        .long_value  = { \
+            .lv_tag = TAG_FROM_SIGN_AND_SIZE( \
+                (val) == 0 ? 0 : ((val) < 0 ? -1 : 1), \
+                (val) == 0 ? 0 : 1), \
+            { ((val) >= 0 ? (val) : -(val)) }, \
+        } \
+    }
+
+static PyLongObject _IntegrationType_MEAN = _Py_IntegrationTypeType_DIGIT_INIT(MEAN);
+static PyLongObject _IntegrationType_MIN = _Py_IntegrationTypeType_DIGIT_INIT(MIN);
+static PyLongObject _IntegrationType_MAX = _Py_IntegrationTypeType_DIGIT_INIT(MAX);
+static PyLongObject _IntegrationType_FIRST = _Py_IntegrationTypeType_DIGIT_INIT(FIRST);
+static PyLongObject _IntegrationType_LAST = _Py_IntegrationTypeType_DIGIT_INIT(LAST);
+#endif
 
 #define BPy_IntegrationType_MEAN ((PyObject *)&_IntegrationType_MEAN)
 #define BPy_IntegrationType_MIN ((PyObject *)&_IntegrationType_MIN)
--- a/source/blender/freestyle/intern/python/BPy_MediumType.cpp
+++ b/source/blender/freestyle/intern/python/BPy_MediumType.cpp
@@ -73,6 +73,7 @@ PyTypeObject MediumType_Type = {
 
 /*-----------------------BPy_IntegrationType instance definitions -------------------------*/
 
+#if PY_VERSION_HEX < 0x030c0000 /* older than Python 3.12 */
 PyLongObject _BPy_MediumType_DRY_MEDIUM = {
     PyVarObject_HEAD_INIT(&MediumType_Type, 1){Stroke::DRY_MEDIUM},
 };
@@ -82,6 +83,24 @@ PyLongObject _BPy_MediumType_HUMID_MEDIU
 PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = {
     PyVarObject_HEAD_INIT(&MediumType_Type, 1){Stroke::OPAQUE_MEDIUM},
 };
+#else
+#define NON_SIZE_BITS 3
+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
+#define _Py_MediumType_DIGIT_INIT(val) \
+    { \
+        .ob_base = PyObject_HEAD_INIT(&MediumType_Type) \
+        .long_value  = { \
+            .lv_tag = TAG_FROM_SIGN_AND_SIZE( \
+                (val) == 0 ? 0 : ((val) < 0 ? -1 : 1), \
+                (val) == 0 ? 0 : 1), \
+            { ((val) >= 0 ? (val) : -(val)) }, \
+        } \
+    }
+
+PyLongObject _BPy_MediumType_DRY_MEDIUM = _Py_MediumType_DIGIT_INIT(Stroke::DRY_MEDIUM);
+PyLongObject _BPy_MediumType_HUMID_MEDIUM = _Py_MediumType_DIGIT_INIT(Stroke::HUMID_MEDIUM);
+PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = _Py_MediumType_DIGIT_INIT(Stroke::OPAQUE_MEDIUM);
+#endif
 
 //-------------------MODULE INITIALIZATION--------------------------------
 
--- a/source/blender/freestyle/intern/python/BPy_Nature.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Nature.cpp
@@ -137,6 +137,7 @@ PyTypeObject Nature_Type = {
 
 /*-----------------------BPy_Nature instance definitions ----------------------------------*/
 
+#if PY_VERSION_HEX < 0x030c0000 /* older than Python 3.12 */
 static PyLongObject _Nature_POINT = {PyVarObject_HEAD_INIT(&Nature_Type, 0){Nature::POINT}};
 static PyLongObject _Nature_S_VERTEX = {PyVarObject_HEAD_INIT(&Nature_Type, 1){Nature::S_VERTEX}};
 static PyLongObject _Nature_VIEW_VERTEX = {
@@ -159,6 +160,36 @@ static PyLongObject _Nature_MATERIAL_BOU
     PyVarObject_HEAD_INIT(&Nature_Type, 1){Nature::MATERIAL_BOUNDARY}};
 static PyLongObject _Nature_EDGE_MARK = {
     PyVarObject_HEAD_INIT(&Nature_Type, 1){Nature::EDGE_MARK}};
+#else
+#define NON_SIZE_BITS 3
+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
+#define _Py_Nature_TypeType_DIGIT_INIT(val) \
+    { \
+        .ob_base = PyObject_HEAD_INIT(&Nature_Type) \
+        .long_value  = { \
+            .lv_tag = TAG_FROM_SIGN_AND_SIZE( \
+                (val) == 0 ? 0 : ((val) < 0 ? -1 : 1), \
+                (val) == 0 ? 0 : 1), \
+            { ((val) >= 0 ? (val) : -(val)) }, \
+        } \
+    }
+
+static PyLongObject _Nature_POINT = _Py_Nature_TypeType_DIGIT_INIT(Nature::POINT);
+static PyLongObject _Nature_S_VERTEX = _Py_Nature_TypeType_DIGIT_INIT(Nature::S_VERTEX);
+static PyLongObject _Nature_VIEW_VERTEX = _Py_Nature_TypeType_DIGIT_INIT(Nature::VIEW_VERTEX);
+static PyLongObject _Nature_NON_T_VERTEX = _Py_Nature_TypeType_DIGIT_INIT(Nature::NON_T_VERTEX);
+static PyLongObject _Nature_T_VERTEX = _Py_Nature_TypeType_DIGIT_INIT(Nature::T_VERTEX);
+static PyLongObject _Nature_CUSP = _Py_Nature_TypeType_DIGIT_INIT(Nature::CUSP);
+static PyLongObject _Nature_NO_FEATURE = _Py_Nature_TypeType_DIGIT_INIT(Nature::NO_FEATURE);
+static PyLongObject _Nature_SILHOUETTE = _Py_Nature_TypeType_DIGIT_INIT(Nature::SILHOUETTE);
+static PyLongObject _Nature_BORDER = _Py_Nature_TypeType_DIGIT_INIT(Nature::BORDER);
+static PyLongObject _Nature_CREASE = _Py_Nature_TypeType_DIGIT_INIT(Nature::CREASE);
+static PyLongObject _Nature_RIDGE = _Py_Nature_TypeType_DIGIT_INIT(Nature::RIDGE);
+static PyLongObject _Nature_VALLEY = _Py_Nature_TypeType_DIGIT_INIT(Nature::VALLEY);
+static PyLongObject _Nature_SUGGESTIVE_CONTOUR = _Py_Nature_TypeType_DIGIT_INIT(Nature::SUGGESTIVE_CONTOUR);
+static PyLongObject _Nature_MATERIAL_BOUNDARY = _Py_Nature_TypeType_DIGIT_INIT(Nature::MATERIAL_BOUNDARY);
+static PyLongObject _Nature_EDGE_MARK = _Py_Nature_TypeType_DIGIT_INIT(Nature::EDGE_MARK);
+#endif
 
 #define BPy_Nature_POINT ((PyObject *)&_Nature_POINT)
 #define BPy_Nature_S_VERTEX ((PyObject *)&_Nature_S_VERTEX)
@@ -249,7 +280,12 @@ static PyObject *BPy_Nature_bitwise(PyOb
   else {
     result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1);
     if (result) {
+#if PY_VERSION_HEX >= 0x030c0000 /* Python 3.12 and newer */
+      result->i.long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE((v > 0 ? 1 : -1), 1);
+      result->i.long_value.ob_digit[0] = v;
+#else
       result->i.ob_digit[0] = v;
+#endif
     }
   }
   return (PyObject *)result;
