Blender: build with python 3.9

This commit is contained in:
Gerasim Troeglazov
2022-01-12 22:24:38 +10:00
parent c98ed50318
commit 26ee2b8e4d
2 changed files with 425 additions and 24 deletions

View File

@@ -10,7 +10,7 @@ benefit from its unified pipeline and responsive development process."
HOMEPAGE="https://www.blender.org/"
COPYRIGHT="2002-2018 Blender Foundation"
LICENSE="GNU GPL v2"
REVISION="26"
REVISION="27"
SOURCE_URI="https://download.blender.org/source/blender-$portVersion.tar.gz"
CHECKSUM_SHA256="4c944c304a49e68ac687ea06f5758204def049b66dc211e1cffa1857716393bc"
PATCHES="
@@ -24,7 +24,7 @@ ADDITIONAL_FILES="
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
PYTHON_VERSION="3.6"
PYTHON_VERSION="3.9"
PROVIDES="
blender$secondaryArchSuffix = $portVersion
@@ -75,7 +75,7 @@ REQUIRES="
lib:libpcre$secondaryArchSuffix
lib:libpng16$secondaryArchSuffix
lib:libpugixml$secondaryArchSuffix
lib:libpython${PYTHON_VERSION}m$secondaryArchSuffix
lib:libpython${PYTHON_VERSION}$secondaryArchSuffix
lib:libsdl2_2.0$secondaryArchSuffix
lib:libsndfile$secondaryArchSuffix
lib:libtbb$secondaryArchSuffix
@@ -127,7 +127,7 @@ BUILD_REQUIRES="
devel:libpcre$secondaryArchSuffix
devel:libpng16$secondaryArchSuffix
devel:libpugixml$secondaryArchSuffix
devel:libpython${PYTHON_VERSION}m$secondaryArchSuffix
devel:libpython${PYTHON_VERSION}$secondaryArchSuffix
devel:libsdl2_2.0$secondaryArchSuffix
devel:libsndfile$secondaryArchSuffix
devel:libtbb$secondaryArchSuffix
@@ -155,10 +155,7 @@ BUILD_PREREQUIRES="
PATCH()
{
# Blender 2.79 doesn't support Python3.7 correctly
# and Python3.6 package doesn't provide cmd:python3.
# This should be removed if we switch to Blender 2.8x.
find . -type f -name "*.py" | xargs sed -i -e 's,python3,python3.6,g'
find . -type f -name "*.py" | xargs sed -i -e 's,python3,python3.9,g'
}
BUILD()
@@ -183,8 +180,8 @@ BUILD()
# Haiku specific settings
BLENDER_PLATFORM_SPECIFIC="-DCMAKE_INSTALL_PREFIX:PATH=$appsDir/Blender \
-DPYTHON_VERSION=${PYTHON_VERSION} \
-DPYTHON_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/python${PYTHON_VERSION}m/ \
-DPYTHON_LIBRARY=`finddir B_SYSTEM_LIB_DIRECTORY`${secondaryArchSubDir}/libpython${PYTHON_VERSION}m.so.1.0 \
-DPYTHON_INCLUDE_DIR=`finddir B_SYSTEM_HEADERS_DIRECTORY`/python${PYTHON_VERSION}/ \
-DPYTHON_LIBRARY=`finddir B_SYSTEM_LIB_DIRECTORY`${secondaryArchSubDir}/libpython${PYTHON_VERSION}.so.1.0 \
-DPYTHON_EXECUTABLE=/bin/python${PYTHON_VERSION} \
-DPYTHON_NUMPY_PATH=`finddir B_SYSTEM_LIB_DIRECTORY`/python${PYTHON_VERSION}/vendor-packages \
-DPYTHON_REQUESTS_PATH=`finddir B_SYSTEM_LIB_DIRECTORY`/python${PYTHON_VERSION}/vendor-packages \

View File

@@ -1,4 +1,4 @@
From 1868f0c5c6908bb332d79c15811e27d46e9b7b23 Mon Sep 17 00:00:00 2001
From 3d937bd732582ec1017d28ec7f97f8d3c993ddea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Tue, 19 Sep 2017 23:03:48 +0200
Subject: Haiku patchset
@@ -154,7 +154,7 @@ index b819c51..9fb3fbf 100644
2.30.2
From ff2b374cb3f6e2e77b3db5169d52767002540b16 Mon Sep 17 00:00:00 2001
From 75ce13adce97d766020f7438333aa5d1cd6542bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Tue, 19 Sep 2017 23:15:20 +0200
Subject: Haiku SDL2 check fix
@@ -177,7 +177,7 @@ index 2a835cf..61b7dee 100644
2.30.2
From 0e7f3d469d9eb34951005b9f71a6f799390a5253 Mon Sep 17 00:00:00 2001
From 59f7447e8055eae5636071e56f18da879b15add0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Tue, 19 Sep 2017 23:52:27 +0200
Subject: In-tree glog supporting patches
@@ -376,7 +376,7 @@ index 0000000..4e6703b
2.30.2
From bde7ee716d9e7be1e4719686ef1d41b75d869390 Mon Sep 17 00:00:00 2001
From 76b48d2aa793c30ce358158e48e1476fbea55ded Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 16 Dec 2017 17:04:56 +0100
Subject: OpenCollada support
@@ -406,7 +406,7 @@ index 63bc520..28cf0b9 100644
2.30.2
From 4f30ebe4fa64d8325f7a7832b5d78587dac71def Mon Sep 17 00:00:00 2001
From 433f32fa2ae04138d74259041c6278889c97382d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Sat, 4 Aug 2018 12:42:53 +0200
Subject: FFMPEG4 patches
@@ -529,7 +529,7 @@ index e1b3abc..1850ffd 100644
2.30.2
From 583d2336f330ee7bbf1bf8f9d46ed2d238fa29fa Mon Sep 17 00:00:00 2001
From 3495a84d45f730a480034d697c3e67b8860507cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Thu, 22 Aug 2019 18:07:13 +0200
Subject: Build fixes from FreeBSD
@@ -568,7 +568,7 @@ index 62f76db..1f3b64f 100644
2.30.2
From ab1f49457cd467e03eb2560b69186390680bccaf Mon Sep 17 00:00:00 2001
From e8b2d163fa8dea54a1452d50acd1bd86cd0e2055 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 7 Nov 2019 18:35:57 +0100
Subject: applying patch blender-2.79b-gcc-8.patch
@@ -604,7 +604,7 @@ index c8a253f..bd35f82 100644
2.30.2
From 2e4bc04aa1a945e0643236bc1c955925c8f8d1d5 Mon Sep 17 00:00:00 2001
From e146e78c8cb1a88b36a2329a201d0896d738c695 Mon Sep 17 00:00:00 2001
From: Sergey Sharybin <sergey.vfx@gmail.com>
Date: Tue, 11 Dec 2018 12:17:26 +0100
Subject: Update code to be compatible with OIIO 2.0
@@ -894,7 +894,7 @@ index b123d50..7f2fac9 100644
2.30.2
From 4daac7b836266516b1cd0adc4a71581cf11a0395 Mon Sep 17 00:00:00 2001
From 64392d166b07c2594ad95a9fa419515a533cf586 Mon Sep 17 00:00:00 2001
From: X512 <danger_mail@list.ru>
Date: Wed, 29 Jan 2020 14:07:31 +0900
Subject: Haiku: fix build for 32 bit
@@ -917,7 +917,7 @@ index 587febe..d25d7f8 100644
2.30.2
From 664eef415a05ffe7e1f4901d2efeb40160c1eda9 Mon Sep 17 00:00:00 2001
From 76f03162bc2b06ec62032e2ffb43062c9cb3f462 Mon Sep 17 00:00:00 2001
From: X512 <danger_mail@list.ru>
Date: Wed, 29 Jan 2020 17:30:56 +0900
Subject: Fix TLS for haiku
@@ -940,7 +940,7 @@ index 60da6b3..8ad0d69 100644
2.30.2
From 25d759839b15857ebc7ece82c32c0a9e08712ff7 Mon Sep 17 00:00:00 2001
From f3ac7572d6016fd8b86837c52adadf486343fedd Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 19 Mar 2021 11:07:00 +1000
Subject: Fix hangs on exit
@@ -976,7 +976,7 @@ index 7608b01..ec274af 100644
2.30.2
From 46478538d18b46a8ffa8d62c77ce9880efaf3854 Mon Sep 17 00:00:00 2001
From ebff020d31641f7d26fbcdad174c89acb484b7e3 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 22 Aug 2021 15:20:53 +1000
Subject: Use OpenEXR 3.x
@@ -1029,7 +1029,7 @@ index 5ad42bd..76204bc 100644
2.30.2
From 6e831779c90d6a40b7075ff4614070531eaa6a41 Mon Sep 17 00:00:00 2001
From b091801032b4f6caad4b2da1acc0ae532b185757 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 27 Dec 2021 14:46:03 +1000
Subject: Link with system ICU
@@ -1052,7 +1052,7 @@ index 9eb6985..0573950 100644
2.30.2
From bc627d36ce45a5653f61acc3162e235d88cdd280 Mon Sep 17 00:00:00 2001
From 9f096917470ff595ab4a4409b03dd821ba7f81be Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 27 Dec 2021 14:46:55 +1000
Subject: Fix for openexr3
@@ -1074,3 +1074,407 @@ index 5392387..9dc3200 100644
--
2.30.2
From b9e5b97547071a4dede5da58a9b76f7314c4d7ac Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 12 Jan 2022 22:04:25 +1000
Subject: applying patch blender-2.79-python-3.7-fix.patch
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 0d3781c..832a872 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -7385,10 +7385,12 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
if (!(flag & PROP_REGISTER))
continue;
+ /* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */
identifier = RNA_property_identifier(prop);
item = PyObject_GetAttrString(py_class, identifier);
if (item == NULL) {
+ PyErr_Clear();
/* Sneaky workaround to use the class name as the bl_idname */
#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
@@ -7404,6 +7406,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
} \
Py_DECREF(item); \
} \
+ else { \
+ PyErr_Clear(); \
+ } \
} /* intentionally allow else here */
if (false) {} /* needed for macro */
--
2.30.2
From 155d0e83a553bad0aeb44cca56a5f84cb5fc59ad Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 12 Jan 2022 22:04:25 +1000
Subject: applying patch blender-2.79-python-3.8-fix.patch
diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c
index d5973ba..d7324ea 100644
--- a/source/blender/python/bmesh/bmesh_py_api.c
+++ b/source/blender/python/bmesh/bmesh_py_api.c
@@ -196,7 +196,7 @@ PyObject *BPyInit_bmesh(void)
{
PyObject *mod;
PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *sys_modules = PyImport_GetModuleDict();
BPy_BM_init_types();
BPy_BM_init_types_select();
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 5d6a7c5..3435c8c 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -1792,7 +1792,7 @@ PyObject *BPyInit_idprop(void)
{
PyObject *mod;
PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *sys_modules = PyImport_GetModuleDict();
mod = PyModule_Create(&IDProp_module_def);
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 861e2db..a3bcadd 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -638,9 +638,16 @@ PyObject *PyC_UnicodeFromByte(const char *str)
****************************************************************************/
PyObject *PyC_DefaultNameSpace(const char *filename)
{
+ #if PY_VERSION_HEX >= 0x03080000
+ PyObject *modules = PyImport_GetModuleDict();
+ PyObject *builtins = PyEval_GetBuiltins();
+ #else
PyInterpreterState *interp = PyThreadState_GET()->interp;
+ PyObject *modules = interp->modules;
+ PyObject *builtins = interp->builtins;
+ #endif
PyObject *mod_main = PyModule_New("__main__");
- PyDict_SetItemString(interp->modules, "__main__", mod_main);
+ PyDict_SetItemString(modules, "__main__", mod_main);
Py_DECREF(mod_main); /* sys.modules owns now */
PyModule_AddStringConstant(mod_main, "__name__", "__main__");
if (filename) {
@@ -648,23 +655,33 @@ PyObject *PyC_DefaultNameSpace(const char *filename)
* note: this wont map to a real file when executing text-blocks and buttons. */
PyModule_AddObject(mod_main, "__file__", PyC_UnicodeFromByte(filename));
}
- PyModule_AddObject(mod_main, "__builtins__", interp->builtins);
- Py_INCREF(interp->builtins); /* AddObject steals a reference */
+ PyModule_AddObject(mod_main, "__builtins__", builtins);
+ Py_INCREF(builtins); /* AddObject steals a reference */
return PyModule_GetDict(mod_main);
}
/* restore MUST be called after this */
void PyC_MainModule_Backup(PyObject **main_mod)
{
+ #if PY_VERSION_HEX >= 0x03080000
+ PyObject *modules = PyImport_GetModuleDict();
+ #else
PyInterpreterState *interp = PyThreadState_GET()->interp;
- *main_mod = PyDict_GetItemString(interp->modules, "__main__");
+ PyObject *modules = interp->modules;
+ #endif
+ *main_mod = PyDict_GetItemString(modules, "__main__");
Py_XINCREF(*main_mod); /* don't free */
}
void PyC_MainModule_Restore(PyObject *main_mod)
{
+ #if PY_VERSION_HEX >= 0x03080000
+ PyObject *modules = PyImport_GetModuleDict();
+ #else
PyInterpreterState *interp = PyThreadState_GET()->interp;
- PyDict_SetItemString(interp->modules, "__main__", main_mod);
+ PyObject *modules = interp->modules;
+ #endif
+ PyDict_SetItemString(modules, "__main__", main_mod);
Py_XDECREF(main_mod);
}
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 20cfd36..2e99b8b 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -530,7 +530,7 @@ static bool python_script_exec(
if (py_dict) {
#ifdef PYMODULE_CLEAR_WORKAROUND
- PyModuleObject *mmod = (PyModuleObject *)PyDict_GetItemString(PyThreadState_GET()->interp->modules, "__main__");
+ PyModuleObject *mmod = (PyModuleObject *)PyDict_GetItemString(PyImport_GetModuleDict(), "__main__");
PyObject *dict_back = mmod->md_dict;
/* freeing the module will clear the namespace,
* gives problems running classes defined in this namespace being used later. */
diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c
index 48230a7..25016c5 100644
--- a/source/blender/python/intern/gpu.c
+++ b/source/blender/python/intern/gpu.c
@@ -323,7 +323,7 @@ PyObject *GPU_initPython(void)
{
PyObject *module;
PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *sys_modules = PyImport_GetModuleDict();
module = PyInit_gpu();
@@ -334,7 +334,7 @@ PyObject *GPU_initPython(void)
PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
Py_INCREF(submodule);
- PyDict_SetItem(PyImport_GetModuleDict(), PyModule_GetNameObject(module), module);
+ PyDict_SetItem(sys_modules, PyModule_GetNameObject(module), module);
return module;
}
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 96ae0a9..21d3624 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -622,7 +622,7 @@ PyMODINIT_FUNC PyInit_mathutils(void)
{
PyObject *mod;
PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *sys_modules = PyImport_GetModuleDict();
if (PyType_Ready(&vector_Type) < 0)
return NULL;
diff --git a/source/blender/python/mathutils/mathutils_noise.c b/source/blender/python/mathutils/mathutils_noise.c
index 143e51e..98c5371 100644
--- a/source/blender/python/mathutils/mathutils_noise.c
+++ b/source/blender/python/mathutils/mathutils_noise.c
@@ -840,6 +840,7 @@ static struct PyModuleDef M_Noise_module_def = {
/*----------------------------MODULE INIT-------------------------*/
PyMODINIT_FUNC PyInit_mathutils_noise(void)
{
+ PyObject *sys_modules = PyImport_GetModuleDict();
PyObject *submodule = PyModule_Create(&M_Noise_module_def);
PyObject *item_types, *item_metrics;
@@ -847,11 +848,11 @@ PyMODINIT_FUNC PyInit_mathutils_noise(void)
setRndSeed(0);
PyModule_AddObject(submodule, "types", (item_types = PyInit_mathutils_noise_types()));
- PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.types", item_types);
+ PyDict_SetItemString(sys_modules, "noise.types", item_types);
Py_INCREF(item_types);
PyModule_AddObject(submodule, "distance_metrics", (item_metrics = PyInit_mathutils_noise_metrics()));
- PyDict_SetItemString(PyThreadState_GET()->interp->modules, "noise.distance_metrics", item_metrics);
+ PyDict_SetItemString(sys_modules, "noise.distance_metrics", item_metrics);
Py_INCREF(item_metrics);
return submodule;
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 97a7e16..5d21c53 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -2239,7 +2239,7 @@ PyMODINIT_FUNC initBGE(void)
{
PyObject *mod;
PyObject *submodule;
- PyObject *sys_modules = PyThreadState_GET()->interp->modules;
+ PyObject *sys_modules = PyImport_GetModuleDict();
const char *mod_full;
mod = PyModule_Create(&BGE_module_def);
--
2.30.2
From 8575097ea31a529e427f8b39c0ab835b8b5d5b16 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 12 Jan 2022 22:04:25 +1000
Subject: applying patch python3.9.patch
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index e368e88..ae598bb 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -48,7 +48,8 @@ static PyObject *Matrix_copy_notest(MatrixObject *self, const float *matrix);
static PyObject *Matrix_copy(MatrixObject *self);
static PyObject *Matrix_deepcopy(MatrixObject *self, PyObject *args);
static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *value);
-static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self);
+static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *),
+ MatrixObject *self);
static PyObject *MatrixAccess_CreatePyObject(MatrixObject *matrix, const eMatrixAccess_t type);
static int matrix_row_vector_check(MatrixObject *mat, VectorObject *vec, int row)
@@ -385,14 +386,15 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
-static PyObject *matrix__apply_to_copy(PyNoArgsFunction matrix_func, MatrixObject *self)
+static PyObject *matrix__apply_to_copy(PyObject *(*matrix_func)(MatrixObject *),
+ MatrixObject *self)
{
PyObject *ret = Matrix_copy(self);
if (ret) {
- PyObject *ret_dummy = matrix_func(ret);
+ PyObject *ret_dummy = matrix_func((MatrixObject *)ret);
if (ret_dummy) {
Py_DECREF(ret_dummy);
- return (PyObject *)ret;
+ return ret;
}
else { /* error */
Py_DECREF(ret);
@@ -1598,7 +1600,7 @@ PyDoc_STRVAR(Matrix_adjugated_doc,
);
static PyObject *Matrix_adjugated(MatrixObject *self)
{
- return matrix__apply_to_copy((PyNoArgsFunction)Matrix_adjugate, self);
+ return matrix__apply_to_copy(Matrix_adjugate, self);
}
PyDoc_STRVAR(Matrix_rotate_doc,
@@ -1795,7 +1797,7 @@ PyDoc_STRVAR(Matrix_transposed_doc,
);
static PyObject *Matrix_transposed(MatrixObject *self)
{
- return matrix__apply_to_copy((PyNoArgsFunction)Matrix_transpose, self);
+ return matrix__apply_to_copy(Matrix_transpose, self);
}
/*---------------------------matrix.normalize() ------------------*/
@@ -1842,7 +1844,7 @@ PyDoc_STRVAR(Matrix_normalized_doc,
);
static PyObject *Matrix_normalized(MatrixObject *self)
{
- return matrix__apply_to_copy((PyNoArgsFunction)Matrix_normalize, self);
+ return matrix__apply_to_copy(Matrix_normalize, self);
}
/*---------------------------matrix.zero() -----------------------*/
diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c
index d283c71..322b578 100644
--- a/source/blender/python/mathutils/mathutils_Quaternion.c
+++ b/source/blender/python/mathutils/mathutils_Quaternion.c
@@ -40,7 +40,8 @@
#define QUAT_SIZE 4
-static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self);
+static PyObject *quat__apply_to_copy(PyObject *(*quat_func)(QuaternionObject *),
+ QuaternionObject *self);
static void quat__axis_angle_sanitize(float axis[3], float *angle);
static PyObject *Quaternion_copy(QuaternionObject *self);
static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args);
@@ -381,7 +382,7 @@ PyDoc_STRVAR(Quaternion_normalized_doc,
);
static PyObject *Quaternion_normalized(QuaternionObject *self)
{
- return quat__apply_to_copy((PyNoArgsFunction)Quaternion_normalize, self);
+ return quat__apply_to_copy(Quaternion_normalize, self);
}
PyDoc_STRVAR(Quaternion_invert_doc,
@@ -409,7 +410,7 @@ PyDoc_STRVAR(Quaternion_inverted_doc,
);
static PyObject *Quaternion_inverted(QuaternionObject *self)
{
- return quat__apply_to_copy((PyNoArgsFunction)Quaternion_invert, self);
+ return quat__apply_to_copy(Quaternion_invert, self);
}
PyDoc_STRVAR(Quaternion_identity_doc,
@@ -473,7 +474,7 @@ PyDoc_STRVAR(Quaternion_conjugated_doc,
);
static PyObject *Quaternion_conjugated(QuaternionObject *self)
{
- return quat__apply_to_copy((PyNoArgsFunction)Quaternion_conjugate, self);
+ return quat__apply_to_copy(Quaternion_conjugate, self);
}
PyDoc_STRVAR(Quaternion_copy_doc,
@@ -1146,10 +1147,11 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw
return Quaternion_CreatePyObject(quat, type);
}
-static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObject *self)
+static PyObject *quat__apply_to_copy(PyObject *(*quat_func)(QuaternionObject *),
+ QuaternionObject *self)
{
PyObject *ret = Quaternion_copy(self);
- PyObject *ret_dummy = quat_func(ret);
+ PyObject *ret_dummy = quat_func((QuaternionObject *)ret);
if (ret_dummy) {
Py_DECREF(ret_dummy);
return ret;
diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c
index afc8a30..2f50330 100644
--- a/source/blender/python/mathutils/mathutils_Vector.c
+++ b/source/blender/python/mathutils/mathutils_Vector.c
@@ -92,10 +92,10 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return Vector_CreatePyObject_alloc(vec, size, type);
}
-static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self)
+static PyObject *vec__apply_to_copy(PyObject *(*vec_func)(VectorObject *), VectorObject *self)
{
PyObject *ret = Vector_copy(self);
- PyObject *ret_dummy = vec_func(ret);
+ PyObject *ret_dummy = vec_func((VectorObject *)ret);
if (ret_dummy) {
Py_DECREF(ret_dummy);
return (PyObject *)ret;
@@ -378,7 +378,7 @@ PyDoc_STRVAR(Vector_normalized_doc,
);
static PyObject *Vector_normalized(VectorObject *self)
{
- return vec__apply_to_copy((PyNoArgsFunction)Vector_normalize, self);
+ return vec__apply_to_copy(Vector_normalize, self);
}
PyDoc_STRVAR(Vector_resize_doc,
--
2.30.2
From 9d0b29f31d6a5fec243e6d651fa64e0e3b55c165 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 12 Jan 2022 22:04:26 +1000
Subject: applying patch python3.9_2.patch
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index fbc1456..628e28f 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -35,14 +35,11 @@
/* analogue of PyEval_SaveThread() */
BPy_ThreadStatePtr BPY_thread_save(void)
{
- PyThreadState *tstate = PyThreadState_Swap(NULL);
- /* note: tstate can be NULL when quitting Blender */
-
- if (tstate && PyEval_ThreadsInitialized()) {
- PyEval_ReleaseLock();
+ /* The thread-state can be NULL when quitting Blender. */
+ if (_PyThreadState_UncheckedGet()) {
+ return (BPy_ThreadStatePtr)PyEval_SaveThread();
}
-
- return (BPy_ThreadStatePtr)tstate;
+ return NULL;
}
/* analogue of PyEval_RestoreThread() */
--
2.30.2