diff --git a/srcpkgs/blender/patches/0001-musl-fixes.patch b/srcpkgs/blender/patches/0001-musl-fixes.patch index a32821172cba34..4e0af6c4619da2 100644 --- a/srcpkgs/blender/patches/0001-musl-fixes.patch +++ b/srcpkgs/blender/patches/0001-musl-fixes.patch @@ -14,11 +14,65 @@ Subject: [PATCH 1/2] musl fixes +++ b/extern/glog/src/config_linux.h @@ -14,7 +14,9 @@ #define HAVE_DLFCN_H - + /* Define to 1 if you have the header file. */ +#ifdef __GLIBC__ #define HAVE_EXECINFO_H +#endif - + /* Define if you have the `fcntl' function */ #define HAVE_FCNTL +--- a/source/blender/blenlib/BLI_index_range.hh ++++ b/source/blender/blenlib/BLI_index_range.hh +@@ -38,6 +38,7 @@ + */ + + #include ++#include + #include + + #include "BLI_assert.h" + +--- a/source/blender/blenkernel/BKE_volume_enums.hh ++++ b/source/blender/blenkernel/BKE_volume_enums.hh +@@ -8,7 +8,11 @@ + * \ingroup bli + */ + +-enum VolumeGridType : int8_t { ++enum VolumeGridType ++#ifdef __GLIBC__ ++: int8_t ++#endif ++{ + VOLUME_GRID_UNKNOWN = 0, + VOLUME_GRID_BOOLEAN, + VOLUME_GRID_FLOAT, + +--- a/extern/lzma/Threads.h ++++ b/extern/lzma/Threads.h +@@ -82,7 +82,12 @@ + + #ifdef Z7_AFFINITY_SUPPORTED + ++#ifndef __GLIBC__ ++typedef struct CCpuSet { unsigned long __bits[128/sizeof(long)]; } CCpuSet; ++// because including sched.h doesn't work ++#else + typedef cpu_set_t CCpuSet; ++#endif + #define CpuSet_Zero(p) CPU_ZERO(p) + #define CpuSet_Set(p, cpu) CPU_SET(cpu, p) + #define CpuSet_IsSet(p, cpu) CPU_ISSET(cpu, p) + +--- a/extern/lzma/Threads.c ++++ b/extern/lzma/Threads.c +@@ -265,7 +265,7 @@ + */ + + // ret2 = +- pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet); ++ pthread_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet); + // if (ret2) ret = ret2; + #endif + } diff --git a/srcpkgs/blender/patches/altivec-all.patch b/srcpkgs/blender/patches/altivec-all.patch deleted file mode 100644 index 115e1ea6fd033d..00000000000000 --- a/srcpkgs/blender/patches/altivec-all.patch +++ /dev/null @@ -1,32 +0,0 @@ -This applies a better workaround for C++ type conflicts -in AltiVec/C++, allowing it to build on BE ppc(64). - ---- a/extern/clew/include/clew.h -+++ b/extern/clew/include/clew.h -@@ -370,15 +370,18 @@ typedef unsigned int cl_GLenum; - - /* Define basic vector types */ - /* Workaround for ppc64el platform: conflicts with bool from C++. */ --#if defined( __VEC__ ) && !(defined(__PPC64__) && defined(__LITTLE_ENDIAN__)) -+#if defined(__VEC__) - #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ -- typedef vector unsigned char __cl_uchar16; -- typedef vector signed char __cl_char16; -- typedef vector unsigned short __cl_ushort8; -- typedef vector signed short __cl_short8; -- typedef vector unsigned int __cl_uint4; -- typedef vector signed int __cl_int4; -- typedef vector float __cl_float4; -+ #undef vector -+ #undef bool -+ #undef pixel -+ typedef __vector unsigned char __cl_uchar16; -+ typedef __vector signed char __cl_char16; -+ typedef __vector unsigned short __cl_ushort8; -+ typedef __vector signed short __cl_short8; -+ typedef __vector unsigned int __cl_uint4; -+ typedef __vector signed int __cl_int4; -+ typedef __vector float __cl_float4; - #define __CL_UCHAR16__ 1 - #define __CL_CHAR16__ 1 - #define __CL_USHORT8__ 1 diff --git a/srcpkgs/blender/patches/python-3.12-regex.patch b/srcpkgs/blender/patches/python-3.12-regex.patch deleted file mode 100644 index daba4a859fd157..00000000000000 --- a/srcpkgs/blender/patches/python-3.12-regex.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/scripts/addons/io_import_dxf/dxfgrabber/dxfentities.py -+++ b/scripts/addons/io_import_dxf/dxfgrabber/dxfentities.py -@@ -852,7 +852,7 @@ class MText(DXFEntity): - self.set_default_extrusion() - - def lines(self): -- return self.raw_text.split('\P') -+ return self.raw_text.split(r'\P') - - def plain_text(self, split=False): - chars = [] ---- a/scripts/addons/io_scene_gltf2/io/exp/gltf2_io_image_data.py -+++ b/scripts/addons/io_scene_gltf2/io/exp/gltf2_io_image_data.py -@@ -22,9 +22,9 @@ class ImageData: - return hash(self._data) - - def adjusted_name(self): -- regex_dot = re.compile("\.") -+ regex_dot = re.compile(r"\.") - adjusted_name = re.sub(regex_dot, "_", self.name) -- new_name = "".join([char for char in adjusted_name if char not in "!#$&'()*+,/:;<>?@[\]^`{|}~"]) -+ new_name = "".join([char for char in adjusted_name if char not in r"!#$&'()*+,/:;<>?@[\]^`{|}~"]) - return new_name - - @property ---- a/scripts/modules/bl_i18n_utils/settings.py -+++ b/scripts/modules/bl_i18n_utils/settings.py -@@ -302,7 +302,7 @@ PYGETTEXT_KEYWORDS = (() + - # becomes extremely slow to process some (unrelated) source files. - ((r"\{(?:(?:\s*\"[^\",]+\"\s*,)|(?:\s*\"\\\"\",)|(?:\s*nullptr\s*,)){4}\s*" + - _msg_re + r"\s*,(?:(?:\s*\"[^\"',]+\"\s*,)|(?:\s*nullptr\s*,))(?:[^,]+,){2}" -- + "(?:\|?\s*B_UNIT_DEF_[_A-Z]+\s*)+\}"),) + -+ + r"(?:\|?\s*B_UNIT_DEF_[_A-Z]+\s*)+\}"),) + - - tuple((r"{}\(\s*" + _msg_re + r"\s*,\s*(?:" + - r"\s*,\s*)?(?:".join(_ctxt_re_gen(i) for i in range(PYGETTEXT_MAX_MULTI_CTXT)) + r")?\s*\)").format(it) diff --git a/srcpkgs/blender/patches/python-3.13.patch b/srcpkgs/blender/patches/python-3.13.patch new file mode 100644 index 00000000000000..0dd6f4b95b4d84 --- /dev/null +++ b/srcpkgs/blender/patches/python-3.13.patch @@ -0,0 +1,626 @@ +From d9f38fca5ffe29136cd6f390e318ad8455864582 Mon Sep 17 00:00:00 2001 +From: Campbell Barton +Date: Fri, 18 Oct 2024 12:23:34 +1100 +Subject: [PATCH] PyAPI: support Python 3.13 + +- `_PySet_NextEntry` has been removed, use generic iterator access + which will has some additional overhead as it needs to create + an iterator to access the values. + +- Add v3.13 compatibility defines to account for renaming: + _PyObject_LookupAttr -> PyObject_GetOptionalAttr + _PyLong_AsInt -> PyLong_AsInt + +- Unfortunately use of Python's internal API needs to be used to + inspect op-codes in `bpy_driver.cc`. + +Testing GLTF/FBX IO there isn't any significant performance impact +from these changes. + +Resolves #123871. +--- + .../blender/python/bmesh/bmesh_py_ops_call.cc | 16 +- + source/blender/python/generic/py_capi_rna.cc | 140 ++++++++++-------- + .../blender/python/generic/py_capi_utils.cc | 56 ++++--- + .../blender/python/generic/py_capi_utils.hh | 4 + + .../blender/python/generic/python_compat.hh | 10 +- + .../blender/python/gpu/gpu_py_framebuffer.cc | 6 +- + source/blender/python/intern/bpy.cc | 48 +++--- + source/blender/python/intern/bpy_driver.cc | 37 ++++- + .../python/intern/bpy_library_write.cc | 27 ++-- + source/blender/python/intern/bpy_rna.cc | 6 +- + 10 files changed, 218 insertions(+), 132 deletions(-) + +diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.cc b/source/blender/python/bmesh/bmesh_py_ops_call.cc +index d5a2e6b02ad..624e4d02e98 100644 +--- a/source/blender/python/bmesh/bmesh_py_ops_call.cc ++++ b/source/blender/python/bmesh/bmesh_py_ops_call.cc +@@ -548,11 +548,12 @@ static int bpy_slot_from_py(BMesh *bm, + break; + } + case BMO_OP_SLOT_SUBTYPE_MAP_EMPTY: { +- if (PySet_Size(value) > 0) { ++ if (PySet_GET_SIZE(value) > 0) { ++ PyObject *it = PyObject_GetIter(value); + PyObject *arg_key; +- Py_ssize_t arg_pos = 0; +- Py_ssize_t arg_hash = 0; +- while (_PySet_NextEntry(value, &arg_pos, &arg_key, &arg_hash)) { ++ while ((arg_key = PyIter_Next(it))) { ++ /* Borrow from the set. */ ++ Py_DECREF(arg_key); + + if (bpy_slot_from_py_elem_check((BPy_BMElem *)arg_key, + bm, +@@ -561,11 +562,16 @@ static int bpy_slot_from_py(BMesh *bm, + slot_name, + "invalid key in set") == -1) + { +- return -1; /* error is set in bpy_slot_from_py_elem_check() */ ++ /* Error is set in #bpy_slot_from_py_elem_check(). */ ++ break; + } + + BMO_slot_map_empty_insert(bmop, slot, ((BPy_BMElem *)arg_key)->ele); + } ++ Py_DECREF(it); ++ if (arg_key) { ++ return -1; ++ } + } + break; + } +diff --git a/source/blender/python/generic/py_capi_rna.cc b/source/blender/python/generic/py_capi_rna.cc +index 11827fa0836..a41e474f619 100644 +--- a/source/blender/python/generic/py_capi_rna.cc ++++ b/source/blender/python/generic/py_capi_rna.cc +@@ -75,60 +75,66 @@ BLI_bitmap *pyrna_enum_bitmap_from_set(const EnumPropertyItem *items, + int bitmap_size, + const char *error_prefix) + { +- /* Set looping. */ +- Py_ssize_t pos = 0; +- Py_ssize_t hash = 0; +- PyObject *key; +- ++ BLI_assert(PySet_Check(value)); + BLI_bitmap *bitmap = BLI_BITMAP_NEW(bitmap_size, __func__); + +- while (_PySet_NextEntry(value, &pos, &key, &hash)) { +- const char *param = PyUnicode_AsUTF8(key); +- if (param == nullptr) { +- PyErr_Format(PyExc_TypeError, +- "%.200s expected a string, not %.200s", +- error_prefix, +- Py_TYPE(key)->tp_name); +- goto error; +- } ++ if (PySet_GET_SIZE(value) > 0) { ++ /* Set looping. */ ++ PyObject *it = PyObject_GetIter(value); ++ PyObject *key; ++ while ((key = PyIter_Next(it))) { ++ /* Borrow from the set. */ ++ Py_DECREF(key); + +- int ret; +- if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) { +- goto error; +- } ++ const char *param = PyUnicode_AsUTF8(key); ++ if (param == nullptr) { ++ PyErr_Format(PyExc_TypeError, ++ "%.200s expected a string, not %.200s", ++ error_prefix, ++ Py_TYPE(key)->tp_name); ++ break; ++ } + +- int index = ret; ++ int ret; ++ if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) { ++ break; ++ } + +- if (type_convert_sign) { +- if (type_size == 2) { +- union { +- signed short as_signed; +- ushort as_unsigned; +- } ret_convert; +- ret_convert.as_signed = (signed short)ret; +- index = int(ret_convert.as_unsigned); +- } +- else if (type_size == 1) { +- union { +- signed char as_signed; +- uchar as_unsigned; +- } ret_convert; +- ret_convert.as_signed = (signed char)ret; +- index = int(ret_convert.as_unsigned); +- } +- else { +- BLI_assert_unreachable(); ++ int index = ret; ++ ++ if (type_convert_sign) { ++ if (type_size == 2) { ++ union { ++ signed short as_signed; ++ ushort as_unsigned; ++ } ret_convert; ++ ret_convert.as_signed = (signed short)ret; ++ index = int(ret_convert.as_unsigned); ++ } ++ else if (type_size == 1) { ++ union { ++ signed char as_signed; ++ uchar as_unsigned; ++ } ret_convert; ++ ret_convert.as_signed = (signed char)ret; ++ index = int(ret_convert.as_unsigned); ++ } ++ else { ++ BLI_assert_unreachable(); ++ } + } ++ BLI_assert(index < bitmap_size); ++ BLI_BITMAP_ENABLE(bitmap, index); ++ } ++ Py_DECREF(it); ++ ++ if (key) { ++ MEM_freeN(bitmap); ++ bitmap = nullptr; + } +- BLI_assert(index < bitmap_size); +- BLI_BITMAP_ENABLE(bitmap, index); + } + + return bitmap; +- +-error: +- MEM_freeN(bitmap); +- return nullptr; + } + + int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items, +@@ -136,32 +142,40 @@ int pyrna_enum_bitfield_from_set(const EnumPropertyItem *items, + int *r_value, + const char *error_prefix) + { ++ BLI_assert(PySet_Check(value)); + /* Set of enum items, concatenate all values with OR. */ +- int ret, flag = 0; +- +- /* Set looping. */ +- Py_ssize_t pos = 0; +- Py_ssize_t hash = 0; +- PyObject *key; ++ int flag = 0; + + *r_value = 0; + +- while (_PySet_NextEntry(value, &pos, &key, &hash)) { +- const char *param = PyUnicode_AsUTF8(key); ++ PyObject *key = nullptr; ++ if (PySet_GET_SIZE(value) > 0) { ++ /* Set looping. */ ++ PyObject *it = PyObject_GetIter(value); ++ while ((key = PyIter_Next(it))) { ++ /* Borrow from the set. */ ++ Py_DECREF(key); + +- if (param == nullptr) { +- PyErr_Format(PyExc_TypeError, +- "%.200s expected a string, not %.200s", +- error_prefix, +- Py_TYPE(key)->tp_name); ++ const char *param = PyUnicode_AsUTF8(key); ++ if (param == nullptr) { ++ PyErr_Format(PyExc_TypeError, ++ "%.200s expected a string, not %.200s", ++ error_prefix, ++ Py_TYPE(key)->tp_name); ++ break; ++ } ++ ++ int ret; ++ if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) { ++ break; ++ } ++ ++ flag |= ret; ++ } ++ Py_DECREF(it); ++ if (key) { + return -1; + } +- +- if (pyrna_enum_value_from_id(items, param, &ret, error_prefix) == -1) { +- return -1; +- } +- +- flag |= ret; + } + + *r_value = flag; +diff --git a/source/blender/python/generic/py_capi_utils.cc b/source/blender/python/generic/py_capi_utils.cc +index 3311064e7c5..74c829d717e 100644 +--- a/source/blender/python/generic/py_capi_utils.cc ++++ b/source/blender/python/generic/py_capi_utils.cc +@@ -39,6 +39,11 @@ + # include "BLI_math_base.h" /* isfinite() */ + #endif + ++#if PY_VERSION_HEX <= 0x030c0000 /* <=3.12 */ ++# define PyLong_AsInt _PyLong_AsInt ++# define PyUnicode_CompareWithASCIIString _PyUnicode_EqualToASCIIString ++#endif ++ + /* -------------------------------------------------------------------- */ + /** \name Fast Python to C Array Conversion for Primitive Types + * \{ */ +@@ -874,10 +879,12 @@ static void pyc_exception_buffer_handle_system_exit() + if (!PyErr_ExceptionMatches(PyExc_SystemExit)) { + return; + } +- /* Inspecting, follow Python's logic in #_Py_HandleSystemExit & treat as a regular exception. */ ++/* Inspecting, follow Python's logic in #_Py_HandleSystemExit & treat as a regular exception. */ ++# if 0 /* FIXME: */ + if (_Py_GetConfig()->inspect) { + return; + } ++# endif + + /* NOTE(@ideasman42): A `SystemExit` exception will exit immediately (unless inspecting). + * So print the error and exit now. Without this #PyErr_Display shows the error stack-trace +@@ -1424,11 +1431,6 @@ int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items, + /* set of enum items, concatenate all values with OR */ + int ret, flag = 0; + +- /* set looping */ +- Py_ssize_t pos = 0; +- Py_ssize_t hash = 0; +- PyObject *key; +- + if (!PySet_Check(value)) { + PyErr_Format(PyExc_TypeError, + "%.200s expected a set, not %.200s", +@@ -1439,22 +1441,32 @@ int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items, + + *r_value = 0; + +- while (_PySet_NextEntry(value, &pos, &key, &hash)) { +- const char *param = PyUnicode_AsUTF8(key); ++ if (PySet_GET_SIZE(value) > 0) { ++ PyObject *it = PyObject_GetIter(value); ++ PyObject *key; ++ while ((key = PyIter_Next(it))) { ++ /* Borrow from the set. */ ++ Py_DECREF(key); + +- if (param == nullptr) { +- PyErr_Format(PyExc_TypeError, +- "%.200s set must contain strings, not %.200s", +- error_prefix, +- Py_TYPE(key)->tp_name); ++ const char *param = PyUnicode_AsUTF8(key); ++ if (param == nullptr) { ++ PyErr_Format(PyExc_TypeError, ++ "%.200s set must contain strings, not %.200s", ++ error_prefix, ++ Py_TYPE(key)->tp_name); ++ break; ++ } ++ ++ if (PyC_FlagSet_ValueFromID(items, param, &ret, error_prefix) < 0) { ++ break; ++ } ++ ++ flag |= ret; ++ } ++ Py_DECREF(it); ++ if (key != nullptr) { + return -1; + } +- +- if (PyC_FlagSet_ValueFromID(items, param, &ret, error_prefix) < 0) { +- return -1; +- } +- +- flag |= ret; + } + + *r_value = flag; +@@ -1724,7 +1736,7 @@ static ulong pyc_Long_AsUnsignedLong(PyObject *value) + + int PyC_Long_AsBool(PyObject *value) + { +- const int test = _PyLong_AsInt(value); ++ const int test = PyLong_AsInt(value); + if (UNLIKELY(test == -1 && PyErr_Occurred())) { + return -1; + } +@@ -1737,7 +1749,7 @@ int PyC_Long_AsBool(PyObject *value) + + int8_t PyC_Long_AsI8(PyObject *value) + { +- const int test = _PyLong_AsInt(value); ++ const int test = PyLong_AsInt(value); + if (UNLIKELY(test == -1 && PyErr_Occurred())) { + return -1; + } +@@ -1750,7 +1762,7 @@ int8_t PyC_Long_AsI8(PyObject *value) + + int16_t PyC_Long_AsI16(PyObject *value) + { +- const int test = _PyLong_AsInt(value); ++ const int test = PyLong_AsInt(value); + if (UNLIKELY(test == -1 && PyErr_Occurred())) { + return -1; + } +diff --git a/source/blender/python/generic/py_capi_utils.hh b/source/blender/python/generic/py_capi_utils.hh +index 4a641f78471..81740e0d0ad 100644 +--- a/source/blender/python/generic/py_capi_utils.hh ++++ b/source/blender/python/generic/py_capi_utils.hh +@@ -339,7 +339,11 @@ uint64_t PyC_Long_AsU64(PyObject *value); + /* inline so type signatures match as expected */ + Py_LOCAL_INLINE(int32_t) PyC_Long_AsI32(PyObject *value) + { ++#if PY_VERSION_HEX <= 0x030c0000 /* <=3.12 */ + return (int32_t)_PyLong_AsInt(value); ++#else ++ return (int32_t)PyLong_AsInt(value); ++#endif + } + Py_LOCAL_INLINE(int64_t) PyC_Long_AsI64(PyObject *value) + { +diff --git a/source/blender/python/generic/python_compat.hh b/source/blender/python/generic/python_compat.hh +index f18d0fb59b3..e2799aeeb46 100644 +--- a/source/blender/python/generic/python_compat.hh ++++ b/source/blender/python/generic/python_compat.hh +@@ -9,9 +9,17 @@ + + #pragma once + ++/* Removes `intialized` member from Python 3.13+. */ ++#if PY_VERSION_HEX >= 0x030d0000 ++# define PY_ARG_PARSER_HEAD_COMPAT() ++#elif PY_VERSION_HEX >= 0x030c0000 + /* Add `intialized` member for Python 3.12+. */ +-#if PY_VERSION_HEX >= 0x030c0000 + # define PY_ARG_PARSER_HEAD_COMPAT() 0, + #else + # define PY_ARG_PARSER_HEAD_COMPAT() + #endif ++ ++/* Python 3.13 made some changes, use the "new" names. */ ++#if PY_VERSION_HEX < 0x030d0000 ++# define PyObject_GetOptionalAttr _PyObject_LookupAttr ++#endif +diff --git a/source/blender/python/gpu/gpu_py_framebuffer.cc b/source/blender/python/gpu/gpu_py_framebuffer.cc +index 899ad21f770..9bef53654df 100644 +--- a/source/blender/python/gpu/gpu_py_framebuffer.cc ++++ b/source/blender/python/gpu/gpu_py_framebuffer.cc +@@ -286,14 +286,14 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach + return false; + } + +- if (c_texture && _PyUnicode_EqualToASCIIString(key, c_texture)) { ++ if (c_texture && PyUnicode_CompareWithASCIIString(key, c_texture)) { + /* Compare only once. */ + c_texture = nullptr; + if (!bpygpu_ParseTexture(value, &tmp_attach.tex)) { + return false; + } + } +- else if (c_layer && _PyUnicode_EqualToASCIIString(key, c_layer)) { ++ else if (c_layer && PyUnicode_CompareWithASCIIString(key, c_layer)) { + /* Compare only once. */ + c_layer = nullptr; + tmp_attach.layer = PyLong_AsLong(value); +@@ -301,7 +301,7 @@ static bool pygpu_framebuffer_new_parse_arg(PyObject *o, GPUAttachment *r_attach + return false; + } + } +- else if (c_mip && _PyUnicode_EqualToASCIIString(key, c_mip)) { ++ else if (c_mip && PyUnicode_CompareWithASCIIString(key, c_mip)) { + /* Compare only once. */ + c_mip = nullptr; + tmp_attach.mip = PyLong_AsLong(value); +diff --git a/source/blender/python/intern/bpy.cc b/source/blender/python/intern/bpy.cc +index 7cdd00fc7a3..42ea76e40ac 100644 +--- a/source/blender/python/intern/bpy.cc ++++ b/source/blender/python/intern/bpy.cc +@@ -610,38 +610,40 @@ PyDoc_STRVAR( + " :rtype: dict\n"); + static PyObject *bpy_wm_capabilities(PyObject *self) + { +- static _Py_Identifier PyId_capabilities = {"_wm_capabilities_", -1}; +- ++ PyObject *py_id_capabilities = PyUnicode_FromString("_wm_capabilities_"); + PyObject *result = nullptr; +- switch (_PyObject_LookupAttrId(self, &PyId_capabilities, &result)) { +- case 1: +- return result; +- case 0: +- break; +- default: +- /* Unlikely, but there may be an error, forward it. */ +- return nullptr; +- } ++ switch (PyObject_GetOptionalAttr(self, py_id_capabilities, &result)) { ++ case 1: { ++ result = PyDict_New(); + +- result = PyDict_New(); +- +- const eWM_CapabilitiesFlag flag = WM_capabilities_flag(); ++ const eWM_CapabilitiesFlag flag = WM_capabilities_flag(); + + #define SetFlagItem(x) \ + PyDict_SetItemString(result, STRINGIFY(x), PyBool_FromLong((WM_CAPABILITY_##x) & flag)); + +- SetFlagItem(CURSOR_WARP); +- SetFlagItem(WINDOW_POSITION); +- SetFlagItem(PRIMARY_CLIPBOARD); +- SetFlagItem(GPU_FRONT_BUFFER_READ); +- SetFlagItem(CLIPBOARD_IMAGES); +- SetFlagItem(DESKTOP_SAMPLE); +- SetFlagItem(INPUT_IME); +- SetFlagItem(TRACKPAD_PHYSICAL_DIRECTION); ++ SetFlagItem(CURSOR_WARP); ++ SetFlagItem(WINDOW_POSITION); ++ SetFlagItem(PRIMARY_CLIPBOARD); ++ SetFlagItem(GPU_FRONT_BUFFER_READ); ++ SetFlagItem(CLIPBOARD_IMAGES); ++ SetFlagItem(DESKTOP_SAMPLE); ++ SetFlagItem(INPUT_IME); ++ SetFlagItem(TRACKPAD_PHYSICAL_DIRECTION); + + #undef SetFlagItem ++ PyObject_SetAttr(self, py_id_capabilities, result); ++ break; ++ } ++ case 0: ++ BLI_assert(result != nullptr); ++ break; ++ default: ++ /* Unlikely, but there may be an error, forward it. */ ++ BLI_assert(result == nullptr); ++ break; ++ } + +- _PyObject_SetAttrId(self, &PyId_capabilities, result); ++ Py_DECREF(py_id_capabilities); + return result; + } + +diff --git a/source/blender/python/intern/bpy_driver.cc b/source/blender/python/intern/bpy_driver.cc +index b32bfbc2a56..e589f0992e1 100644 +--- a/source/blender/python/intern/bpy_driver.cc ++++ b/source/blender/python/intern/bpy_driver.cc +@@ -43,6 +43,13 @@ + # include + #endif + ++#if PY_VERSION_HEX >= 0x030d0000 /* >=3.13 */ ++/* WARNING(@ideasman42): Using `Py_BUILD_CORE` is a last resort, ++ * the alternative would be not to inspect OP-CODES at all. */ ++# define Py_BUILD_CORE ++# include ++#endif ++ + PyObject *bpy_pydriver_Dict = nullptr; + + #ifdef USE_BYTECODE_WHITELIST +@@ -375,7 +382,35 @@ static bool is_opcode_secure(const int opcode) + OK_OP(LOAD_CONST) /* Ok because constants are accepted. */ + OK_OP(LOAD_NAME) /* Ok, because `PyCodeObject.names` is checked. */ + OK_OP(CALL) /* Ok, because we check its "name" before calling. */ +- OK_OP(KW_NAMES) /* Ok, because it's used for calling functions with keyword arguments. */ ++# if PY_VERSION_HEX >= 0x030d0000 ++ OK_OP(CALL_KW) /* Ok, because it's used for calling functions with keyword arguments. */ ++ ++ OK_OP(CALL_FUNCTION_EX); ++ ++ /* OK because the names are checked. */ ++ OK_OP(CALL_ALLOC_AND_ENTER_INIT) ++ OK_OP(CALL_BOUND_METHOD_EXACT_ARGS) ++ OK_OP(CALL_BOUND_METHOD_GENERAL) ++ OK_OP(CALL_BUILTIN_CLASS) ++ OK_OP(CALL_BUILTIN_FAST) ++ OK_OP(CALL_BUILTIN_FAST_WITH_KEYWORDS) ++ OK_OP(CALL_BUILTIN_O) ++ OK_OP(CALL_ISINSTANCE) ++ OK_OP(CALL_LEN) ++ OK_OP(CALL_LIST_APPEND) ++ OK_OP(CALL_METHOD_DESCRIPTOR_FAST) ++ OK_OP(CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS) ++ OK_OP(CALL_METHOD_DESCRIPTOR_NOARGS) ++ OK_OP(CALL_METHOD_DESCRIPTOR_O) ++ OK_OP(CALL_NON_PY_GENERAL) ++ OK_OP(CALL_PY_EXACT_ARGS) ++ OK_OP(CALL_PY_GENERAL) ++ OK_OP(CALL_STR_1) ++ OK_OP(CALL_TUPLE_1) ++ OK_OP(CALL_TYPE_1) ++# else ++ OK_OP(KW_NAMES) /* Ok, because it's used for calling functions with keyword arguments. */ ++# endif + + # if PY_VERSION_HEX < 0x030c0000 + OK_OP(PRECALL) /* Ok, because it's used for calling. */ +diff --git a/source/blender/python/intern/bpy_library_write.cc b/source/blender/python/intern/bpy_library_write.cc +index d1c0b32ac07..59bf476427f 100644 +--- a/source/blender/python/intern/bpy_library_write.cc ++++ b/source/blender/python/intern/bpy_library_write.cc +@@ -136,20 +136,25 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * + PartialWriteContext::IDAddOperations::ADD_DEPENDENCIES | + (use_fake_user ? PartialWriteContext::IDAddOperations::SET_FAKE_USER : 0))}; + +- Py_ssize_t pos, hash; +- PyObject *key; +- ID *id = nullptr; +- +- pos = hash = 0; +- while (_PySet_NextEntry(datablocks, &pos, &key, &hash)) { +- if (!pyrna_id_FromPyObject(key, &id)) { +- PyErr_Format(PyExc_TypeError, "Expected an ID type, not %.200s", Py_TYPE(key)->tp_name); +- return nullptr; +- } +- else { ++ if (PySet_GET_SIZE(datablocks) > 0) { ++ PyObject *it = PyObject_GetIter(datablocks); ++ PyObject *key; ++ while ((key = PyIter_Next(it))) { ++ /* Borrow from the set. */ ++ Py_DECREF(key); ++ ID *id; ++ if (!pyrna_id_FromPyObject(key, &id)) { ++ PyErr_Format(PyExc_TypeError, "Expected an ID type, not %.200s", Py_TYPE(key)->tp_name); ++ break; ++ } + partial_write_ctx.id_add(id, add_options, nullptr); + } ++ Py_DECREF(it); ++ if (key) { ++ return nullptr; ++ } + } ++ + BLI_assert(partial_write_ctx.is_valid()); + + /* write blend */ +diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc +index eb365bf0238..a9cb115f57e 100644 +--- a/source/blender/python/intern/bpy_rna.cc ++++ b/source/blender/python/intern/bpy_rna.cc +@@ -8639,7 +8639,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummy_ptr, + continue; + } + +- /* TODO(@ideasman42): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */ ++ /* TODO(@ideasman42): Use #PyObject_GetOptionalAttr(), also in the macro below. */ + identifier = RNA_property_identifier(prop); + item = PyObject_GetAttrString(py_class, identifier); + +@@ -9263,7 +9263,7 @@ static PyObject *pyrna_register_class(PyObject * /*self*/, PyObject *py_class) + + /* Call classed register method. + * Note that zero falls through, no attribute, no error. */ +- switch (_PyObject_LookupAttr(py_class, bpy_intern_str_register, &py_cls_meth)) { ++ switch (PyObject_GetOptionalAttr(py_class, bpy_intern_str_register, &py_cls_meth)) { + case 1: { + PyObject *ret = PyObject_CallObject(py_cls_meth, nullptr); + Py_DECREF(py_cls_meth); +@@ -9378,7 +9378,7 @@ static PyObject *pyrna_unregister_class(PyObject * /*self*/, PyObject *py_class) + + /* Call classed unregister method. + * Note that zero falls through, no attribute, no error. */ +- switch (_PyObject_LookupAttr(py_class, bpy_intern_str_unregister, &py_cls_meth)) { ++ switch (PyObject_GetOptionalAttr(py_class, bpy_intern_str_unregister, &py_cls_meth)) { + case 1: { + PyObject *ret = PyObject_CallObject(py_cls_meth, nullptr); + Py_DECREF(py_cls_meth); diff --git a/srcpkgs/blender/patches/python3.12-pylongobject.patch b/srcpkgs/blender/patches/python3.12-pylongobject.patch deleted file mode 100644 index 80b326809cc95f..00000000000000 --- a/srcpkgs/blender/patches/python3.12-pylongobject.patch +++ /dev/null @@ -1,134 +0,0 @@ -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; diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template index 7e321a9ad525cd..668d68647ba7e0 100644 --- a/srcpkgs/blender/template +++ b/srcpkgs/blender/template @@ -1,7 +1,7 @@ # Template file for 'blender' pkgname=blender -version=4.0.2 -revision=3 +version=4.3.0 +revision=1 archs="x86_64* ppc64*" build_style="cmake" pycompile_dirs="usr/share/blender/${version%.*}/scripts" @@ -24,14 +24,14 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel libspnav-devel libwebp-devel potrace-devel Haru-devel - pulseaudio-devel eigen lzo-devel" + pulseaudio-devel eigen lzo-devel vulkan-loader-devel shaderc" depends="desktop-file-utils hicolor-icon-theme" short_desc="3D graphics creation suite" maintainer="Enno Boland " license="GPL-3.0-or-later" homepage="https://www.blender.org" distfiles="https://download.blender.org/source/blender-${version}.tar.xz" -checksum=aaa0e729da7591cfbf45772af76345977daaa7b11a0af35d98f9313e246077a3 +checksum=a2c73d338768509be210aeb66730efe6076ec1be36668a1acd0be35a9de12aea python_version=3 LDFLAGS="-Wl,-z,stack-size=2097152" # Blender tests are executed against a system installation of blender. This