diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-21 15:02:41 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-22 06:41:00 +0300 |
commit | 243e28b73b888fd578530cc637d511ab0b1cafe3 (patch) | |
tree | 62acefba9514192740b0b4f9ed58b5853aa421da | |
parent | a920f32ccd0bdbd24317c79648e9fb91dc108d15 (diff) |
PyAPI: Support Python 3.9 (for VFX platform support)
Support Python 3.9, part of VFX platform support.
The intention of restoring Python 3.9 support is so it's possible to
build a (mostly) VFX compatible version of Blender, not to provide
official builds on the buildbot.
Includes contribution by Brecht.
Reviewed By: brecht
Ref D16030
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 2 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_win32.cmake | 2 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d_toolbar.py | 108 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_capi_utils.h | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_driver.c | 4 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils.c | 4 |
7 files changed, 68 insertions, 60 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c998919622e..f36d16a6ec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -956,8 +956,8 @@ if(WITH_PYTHON) # Do this before main 'platform_*' checks, # because UNIX will search for the old Python paths which may not exist. # giving errors about missing paths before this case is met. - if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.10") - message(FATAL_ERROR "At least Python 3.10 is required to build, but found Python ${PYTHON_VERSION}") + if(DEFINED PYTHON_VERSION AND "${PYTHON_VERSION}" VERSION_LESS "3.9") + message(FATAL_ERROR "At least Python 3.9 is required to build, but found Python ${PYTHON_VERSION}") endif() file(GLOB RESULT "${CMAKE_SOURCE_DIR}/release/scripts/addons") diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index f84be3c5238..9487875033e 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -113,7 +113,7 @@ endif() if(WITH_PYTHON) # Use precompiled libraries by default. - set(PYTHON_VERSION 3.10) + SET(PYTHON_VERSION 3.10 CACHE STRING "Python Version (major and minor only)") if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK) # Normally cached but not since we include them with blender. set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 7e272ea26b0..456f02b0c05 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -497,7 +497,7 @@ if(WITH_JACK) endif() if(WITH_PYTHON) - set(PYTHON_VERSION 3.10) # CACHE STRING) + SET(PYTHON_VERSION 3.10 CACHE STRING "Python Version (major and minor only)") string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) set(PYTHON_LIBRARY ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}.lib) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 892dc9a1e42..49ac6841c35 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -483,68 +483,68 @@ class SelectPaintSlotHelper: have_image = False - match getattr(mode_settings, self.canvas_source_attr_name): - case 'MATERIAL': - if len(ob.material_slots) > 1: - layout.template_list( - "MATERIAL_UL_matslots", "layers", - ob, "material_slots", - ob, "active_material_index", rows=2, - ) - mat = ob.active_material - if mat and mat.texture_paint_images: - row = layout.row() - row.template_list( - "TEXTURE_UL_texpaintslots", "", - mat, "texture_paint_slots", - mat, "paint_active_slot", rows=2, - ) - - if mat.texture_paint_slots: - slot = mat.texture_paint_slots[mat.paint_active_slot] - else: - slot = None - - have_image = slot is not None + canvas_source = getattr(mode_settings, self.canvas_source_attr_name) + if canvas_source == 'MATERIAL': + if len(ob.material_slots) > 1: + layout.template_list( + "MATERIAL_UL_matslots", "layers", + ob, "material_slots", + ob, "active_material_index", rows=2, + ) + mat = ob.active_material + if mat and mat.texture_paint_images: + row = layout.row() + row.template_list( + "TEXTURE_UL_texpaintslots", "", + mat, "texture_paint_slots", + mat, "paint_active_slot", rows=2, + ) + + if mat.texture_paint_slots: + slot = mat.texture_paint_slots[mat.paint_active_slot] else: - row = layout.row() + slot = None - box = row.box() - box.label(text="No Textures") + have_image = slot is not None + else: + row = layout.row() - sub = row.column(align=True) - sub.operator_menu_enum("paint.add_texture_paint_slot", "type", icon='ADD', text="") + box = row.box() + box.label(text="No Textures") - case 'IMAGE': - mesh = ob.data - uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" - layout.template_ID(mode_settings, self.canvas_image_attr_name, new="image.new", open="image.open") - if settings.missing_uvs: - layout.operator("paint.add_simple_uvs", icon='ADD', text="Add UVs") - else: - layout.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) - have_image = getattr(settings, self.canvas_image_attr_name) is not None + sub = row.column(align=True) + sub.operator_menu_enum("paint.add_texture_paint_slot", "type", icon='ADD', text="") - self.draw_image_interpolation(layout=layout, mode_settings=mode_settings) + elif canvas_source == 'IMAGE': + mesh = ob.data + uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else "" + layout.template_ID(mode_settings, self.canvas_image_attr_name, new="image.new", open="image.open") + if settings.missing_uvs: + layout.operator("paint.add_simple_uvs", icon='ADD', text="Add UVs") + else: + layout.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False) + have_image = getattr(settings, self.canvas_image_attr_name) is not None - case 'COLOR_ATTRIBUTE': - mesh = ob.data + self.draw_image_interpolation(layout=layout, mode_settings=mode_settings) - row = layout.row() - col = row.column() - col.template_list( - "MESH_UL_color_attributes_selector", - "color_attributes", - mesh, - "color_attributes", - mesh.color_attributes, - "active_color_index", - rows=3, - ) + elif canvas_source == 'COLOR_ATTRIBUTE': + mesh = ob.data + + row = layout.row() + col = row.column() + col.template_list( + "MESH_UL_color_attributes_selector", + "color_attributes", + mesh, + "color_attributes", + mesh.color_attributes, + "active_color_index", + rows=3, + ) - col = row.column(align=True) - col.operator("geometry.color_attribute_add", icon='ADD', text="") - col.operator("geometry.color_attribute_remove", icon='REMOVE', text="") + col = row.column(align=True) + col.operator("geometry.color_attribute_add", icon='ADD', text="") + col.operator("geometry.color_attribute_remove", icon='REMOVE', text="") if settings.missing_uvs: layout.separator() diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h index 73a5d2ebc79..08d48c5763d 100644 --- a/source/blender/python/intern/bpy_capi_utils.h +++ b/source/blender/python/intern/bpy_capi_utils.h @@ -6,8 +6,8 @@ #pragma once -#if PY_VERSION_HEX < 0x030a0000 -# error "Python 3.10 or greater is required, you'll need to update your Python." +#if PY_VERSION_HEX < 0x03090000 +# error "Python 3.9 or greater is required, you'll need to update your Python." #endif #ifdef __cplusplus diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 04aa203d198..e11821090ab 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -389,7 +389,9 @@ static const bool secure_opcodes[255] = { OK_OP(BINARY_TRUE_DIVIDE), OK_OP(INPLACE_FLOOR_DIVIDE), OK_OP(INPLACE_TRUE_DIVIDE), +#if PY_VERSION_HEX >= 0x030a0000 /* Python3.9 doesn't support. */ OK_OP(GET_LEN), +#endif OK_OP(INPLACE_ADD), OK_OP(INPLACE_SUBTRACT), OK_OP(INPLACE_MULTIPLY), @@ -407,7 +409,9 @@ static const bool secure_opcodes[255] = { OK_OP(INPLACE_OR), OK_OP(LIST_TO_TUPLE), OK_OP(RETURN_VALUE), +#if PY_VERSION_HEX >= 0x030a0000 /* Python3.9 doesn't support. */ OK_OP(ROT_N), +#endif OK_OP(BUILD_TUPLE), OK_OP(BUILD_LIST), OK_OP(BUILD_SET), diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 1aa2cec861c..e709ed849d4 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -76,7 +76,11 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len) x = 0x345678UL; i = 0; while (--len >= 0) { +#if PY_VERSION_HEX < 0x030a0000 + y = _Py_HashDouble((double)(array[i++])); +#else y = _Py_HashDouble(NULL, (double)(array[i++])); +#endif if (y == -1) { return -1; } |