commit: e4f0f72b2f01db2bbb9a3bf66c395a7f1e58e0b5 Author: Paul Zander <negril.nx+gentoo <AT> gmail <DOT> com> AuthorDate: Thu Nov 20 16:03:59 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Nov 28 02:53:06 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e4f0f72b
media-gfx/blender: drop 4.3.2-r4 Signed-off-by: Paul Zander <negril.nx+gentoo <AT> gmail.com> Part-of: https://github.com/gentoo/gentoo/pull/44694 Signed-off-by: Sam James <sam <AT> gentoo.org> media-gfx/blender/Manifest | 2 - media-gfx/blender/blender-4.3.2-r4.ebuild | 806 --------------------- .../blender/files/blender-4.2.9-python3.12.patch | 68 -- .../blender/files/blender-4.2.9-python3.12_1.patch | 39 - .../blender/files/blender-4.2.9-python3.13.patch | 626 ---------------- 5 files changed, 1541 deletions(-) diff --git a/media-gfx/blender/Manifest b/media-gfx/blender/Manifest index a5ca52891dcf..e40bd4a12d29 100644 --- a/media-gfx/blender/Manifest +++ b/media-gfx/blender/Manifest @@ -1,10 +1,8 @@ DIST blender-4.2.16.tar.xz 75352960 BLAKE2B 6be3acce0d8472a78c20faefd0af1b37a70a887a16fe1943a321fe9eb188155d072166d181ec3541bdb64072d1001d6ac38360e8ad7164232c4ea5994208b78a SHA512 11e07e3df21aba85263faa9e0a7fb5be7a0415749b951327f842c8e05c46fce94debf5dfb1f57007e4034d6d7abfec9ef4e94e5bb9c4c57641c52675e0401059 -DIST blender-4.3.2.tar.xz 74473996 BLAKE2B 9a5c8973561f3296b0ec35990ab4951e34f7c0dd5bee3dd120a49989dc8ca7ebfc9610654e8be9d14463af2197626f490324cdd03118db755f5d0b1f7acce375 SHA512 44697faf9acc2c1e75783d432a1a0040339c3445834961a995e95974d4088e75ee5cb647a3908125259d1910d180910e5bc50d34d40d35f33e03197893581477 DIST blender-4.4.1.tar.xz 85518840 BLAKE2B a482a2d246222b5395f5e1c5cfa9fd2dbab0d5dc33145ec5cfaae3e7d7083e65034e1f5b54bc4605ab45905d08c2938c97ab488659d822997ee853c9e34fcc55 SHA512 db6b117b841890b172f4d13c6f38b73f36aae5648ed74f5233eb311328d467644005bd24fb4f9c7ea9b2dad7ff584fc7b3831f5ab34f3f900555c68f4af5b901 DIST blender-4.4.3.tar.xz 85519376 BLAKE2B bb2f93d96b98e4104f1e49f3bd9be8992e37d2005665ad913ccd7e9097fba4823567d0aba3cd6487097d52043c5681fde4489c040e24ae4df6014337eb97f9f5 SHA512 0a500a7abee2e2dea7cdc925539c3f906271525ec88877e12920315552a057072c68806d6cdf7a6eb43b2b7d611e8697c5ad093b22f2402f96a11718538012e6 DIST blender-4.5.5.tar.xz 85095244 BLAKE2B 5578a45300622f71bb7dd679dcaa85f2de0a3db2ddc9e21a6890ed96b83d14f8b617058e8fc648ae0e02b70e5706c05427f9d1cf44848995ca95b5fd074d616f SHA512 14f340e44ee0f2971a9367f35a150bec61d7c378d1a5d60060e16c2e60f8fdffe71d2252e679698aa0a7a6b77e9b353c67d7494e8ba9990f479b834bb6d9b1de DIST blender-5.0.0.tar.xz 88881428 BLAKE2B ca2b5bbbe860597099a310ed4bdb63fb8648d5745e16da59b9ada6fe72ba1d75b884357508ddc62e4b7b1cf7fdfcb028b11d9ded89a64153d511fed3caf78245 SHA512 5f4cf6fa2360ccfbd28c3a0abcf8a4aba7e4d03f7eb7df75bfcfbfb72896cc6628c54d17631e458513fc02ef7f5101a607548c0fcfbafd242d4a2d72864ccf3c -DIST blender-assets-4.3.2.tar.xz 8763844 BLAKE2B 0eca4a7bfb630096dfe9dd5f8c8071d9ca8c1aaab560a8694df4add507c3e8a641a4e0ad197f110b639d2d399a23c5c25af6fb060ca3316e1a44d286f6b23f7e SHA512 ce9483b3e5b83d1b29bdfa3a14f7be7176e85ec50a414213a67badcce3c24cd8da349fee22b08cc95d6e5906420bbcd5c5f15855445da6364e6054f968c20678 DIST blender-test-data-4.4.0.tar.xz 386262908 BLAKE2B 4b7f16f5d19d9569ae19a8e9feeb134841801c89ea64a787c1caa6a4bddce700ebe2a9a15cb2053701c404743dc0749643a1b03fc45f523f792e3729de11f0e8 SHA512 babd235aeb5cf87764b48000dc7776b5e8121d60d930f4aa92ea27cf275608cfc6c3ed47e59d499c85c670dc1ee329e26882e76d8a9a2567b42d3de551a5a9a0 DIST blender-test-data-4.5.0-1.tar.xz 408765680 BLAKE2B b09840a18a78f8972424a58ad6b36c9e30019862c8217211ef09b9f910eb1ca9facc2ad14fb9bbb49dcf7c0ed7e082e7dcfc57c08daad9bf18fed4bfb2588b86 SHA512 09fcbb76a673a1e0c53f35bf60a74f09b5123ea37c99f5f0d027043caad184a16e3eea407c81027229e4a3a5c1ad8e66b4432ed90a9c8980e466e8b4575fa34b DIST blender-test-data-5.0.0.tar.xz 424858204 BLAKE2B 93a35706481204fbfb310c7dad664bcbf95a9e9083a31ab4cf390c756baf7c6687bcd998644161a828c8d909db986512aba62f2ea8fd1d59649eefb45b719be2 SHA512 f03ea7ff5f59a71c08c3e4489ef46f2cbdf2a3680c531e670be1b2f3b323f5931986acf9b7df337e0d2b2762bc7a693b354d71dbc6759d72f95c5672406ef396 diff --git a/media-gfx/blender/blender-4.3.2-r4.ebuild b/media-gfx/blender/blender-4.3.2-r4.ebuild deleted file mode 100644 index 0733437b956c..000000000000 --- a/media-gfx/blender/blender-4.3.2-r4.ebuild +++ /dev/null @@ -1,806 +0,0 @@ -# Copyright 1999-2025 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# shellcheck disable=SC2207 - -# TODO -# - Package Hydra -# https://github.com/Ray-Tracing-Systems/HydraCore -# https://github.com/Ray-Tracing-Systems/HydraAPI -# - Package USD -# https://github.com/PixarAnimationStudios/OpenUSD -# - Package MaterialX -# https://github.com/AcademySoftwareFoundation/MaterialX -# - Package Draco -# https://github.com/google/draco -# - Package Audaspace -# https://github.com/neXyon/audaspace - -EAPI=8 - -PYTHON_COMPAT=( python3_{11..13} ) -# NOTE must match media-libs/osl -LLVM_COMPAT=( {17..18} ) -LLVM_OPTIONAL=1 - -ROCM_SKIP_GLOBALS=1 - -inherit cuda rocm llvm-r1 -inherit eapi9-pipestatus check-reqs flag-o-matic pax-utils python-single-r1 toolchain-funcs virtualx -inherit cmake xdg-utils - -DESCRIPTION="3D Creation/Animation/Publishing System" -HOMEPAGE="https://www.blender.org" - -# NOTE BLENDER_VERSION -# https://projects.blender.org/blender/blender/src/branch/main/source/blender/blenkernel/BKE_blender_version.h -BLENDER_BRANCH="$(ver_cut 1-2)" - -if [[ "${PV}" == *9999* ]]; then - EGIT_LFS="yes" - inherit git-r3 - EGIT_REPO_URI="https://projects.blender.org/blender/blender.git" - EGIT_SUBMODULES=( '*' '-lib/*' ) - - if [[ "${PV}" == 9999* ]]; then - EGIT_BRANCH="main" - else - EGIT_BRANCH="blender-v${BLENDER_BRANCH}-release" - fi - - RESTRICT="!test? ( test )" -else - SRC_URI=" - https://download.blender.org/source/${P}.tar.xz - https://github.com/negril/gentoo-overlay-vendored/raw/refs/heads/blobs/blender-assets-${PV}.tar.xz - " - # BUG upstream returns LFS references instead of files - # SRC_URI+=" - # test? ( - # https://projects.blender.org/blender/blender-test-data/archive/blender-v${BLENDER_BRANCH}-release.tar.gz - # ) - # " - KEYWORDS="amd64 ~arm ~arm64" - RESTRICT="test" # the test archive contains LFS references -fi - -# assets is CC0-1.0 -LICENSE="GPL-3+ cycles? ( Apache-2.0 ) CC0-1.0" -SLOT="${BLENDER_BRANCH}" - -# NOTE +openpgl breaks on very old amd64 hardware -# potentially mirror cpu_flags_x86 + REQUIRED_USE -IUSE=" - alembic +bullet collada +color-management cuda +cycles +cycles-bin-kernels - debug doc +embree +ffmpeg +fftw +fluid +gmp gnome hip jack - jemalloc jpeg2k man +nanovdb ndof nls +oidn openal +openexr +opengl +openmp +openpgl - +opensubdiv +openvdb optix osl +pdf +potrace +pugixml pulseaudio - renderdoc sdl +sndfile +tbb test +tiff +truetype valgrind vulkan wayland +webp X -" - -if [[ "${PV}" == *9999* ]]; then - IUSE+="experimental" -fi - -REQUIRED_USE="${PYTHON_REQUIRED_USE} - || ( opengl vulkan ) - alembic? ( openexr ) - cuda? ( cycles ) - cycles? ( openexr tiff tbb ) - fluid? ( tbb ) - gnome? ( wayland ) - hip? ( cycles ) - nanovdb? ( openvdb ) - openvdb? ( tbb openexr ) - optix? ( cuda ) - osl? ( cycles pugixml ) - test? ( - color-management - jpeg2k - ) -" - -# Library versions for official builds can be found in the blender source directory in: -# build_files/build_environment/cmake/versions.cmake -RDEPEND="${PYTHON_DEPS} - app-arch/zstd - dev-cpp/gflags:= - dev-cpp/glog:= - dev-libs/boost:=[nls?] - dev-libs/lzo:2= - $(python_gen_cond_dep ' - dev-python/cython[${PYTHON_USEDEP}] - dev-python/numpy[${PYTHON_USEDEP}] - dev-python/zstandard[${PYTHON_USEDEP}] - dev-python/requests[${PYTHON_USEDEP}] - ') - media-libs/freetype:=[brotli] - media-libs/libepoxy:= - media-libs/libjpeg-turbo:= - media-libs/libpng:= - media-libs/libsamplerate - <media-libs/openimageio-3:= - virtual/zlib:= - virtual/glu - virtual/libintl - virtual/opengl[X?] - alembic? ( >=media-gfx/alembic-1.8.3-r2[boost(+),hdf(+)] ) - bullet? ( sci-physics/bullet:=[double-precision] ) - collada? ( >=media-libs/opencollada-1.6.68 ) - color-management? ( media-libs/opencolorio:= ) - cuda? ( dev-util/nvidia-cuda-toolkit:= ) - embree? ( media-libs/embree:=[raymask] ) - ffmpeg? ( media-video/ffmpeg:=[encode(+),lame(-),jpeg2k?,opus,theora,vorbis,vpx,x264,xvid] ) - fftw? ( sci-libs/fftw:3.0=[threads] ) - gmp? ( dev-libs/gmp[cxx] ) - gnome? ( gui-libs/libdecor ) - hip? ( - >=dev-util/hip-5.7:= - ) - jack? ( virtual/jack ) - jemalloc? ( dev-libs/jemalloc:= ) - jpeg2k? ( media-libs/openjpeg:2= ) - ndof? ( - app-misc/spacenavd - dev-libs/libspnav - ) - nls? ( virtual/libiconv ) - openal? ( media-libs/openal ) - oidn? ( >=media-libs/oidn-2.1.0 ) - openexr? ( - >=dev-libs/imath-3.1.7:= - >=media-libs/openexr-3.2.1:0= - ) - openpgl? ( media-libs/openpgl:= ) - opensubdiv? ( >=media-libs/opensubdiv-3.6.0-r2[opengl,cuda?,openmp?,tbb?] ) - openvdb? ( - >=media-gfx/openvdb-11.0.0:=[nanovdb?] - dev-libs/c-blosc:= - ) - optix? ( <dev-libs/optix-9:= ) - osl? ( - <media-libs/osl-1.14:=[${LLVM_USEDEP}] - media-libs/mesa[${LLVM_USEDEP}] - ) - pdf? ( media-libs/libharu ) - potrace? ( media-gfx/potrace ) - pugixml? ( dev-libs/pugixml ) - pulseaudio? ( media-libs/libpulse ) - sdl? ( media-libs/libsdl2[sound,joystick] ) - sndfile? ( media-libs/libsndfile ) - tbb? ( dev-cpp/tbb:= ) - tiff? ( media-libs/tiff:= ) - valgrind? ( dev-debug/valgrind ) - wayland? ( - >=dev-libs/wayland-1.12 - >=dev-libs/wayland-protocols-1.15 - >=x11-libs/libxkbcommon-0.2.0 - dev-util/wayland-scanner - media-libs/mesa[wayland] - sys-apps/dbus - ) - vulkan? ( - media-libs/shaderc - dev-util/spirv-tools - dev-util/glslang - media-libs/vulkan-loader - ) - truetype? ( - media-libs/harfbuzz - ) - renderdoc? ( - media-gfx/renderdoc - ) - X? ( - x11-libs/libX11 - x11-libs/libXi - x11-libs/libXxf86vm - ) -" - -DEPEND="${RDEPEND} - dev-cpp/eigen:= -" - -if [[ "${PV}" == *9999* ]]; then -DEPEND+=" - test? ( - experimental? ( - wayland? ( - dev-libs/weston - ) - ) - ) -" -fi - -BDEPEND=" - virtual/pkgconfig - doc? ( - app-text/doxygen[dot] - dev-python/sphinx[latex] - dev-texlive/texlive-bibtexextra - dev-texlive/texlive-fontsextra - dev-texlive/texlive-fontutils - dev-texlive/texlive-latex - dev-texlive/texlive-latexextra - ) - vulkan? ( - dev-util/spirv-headers - dev-util/vulkan-headers - ) - nls? ( sys-devel/gettext ) - wayland? ( - dev-util/wayland-scanner - ) - X? ( - x11-base/xorg-proto - ) -" - -PATCHES=( - "${FILESDIR}/${PN}-4.0.2-FindClang.patch" - "${FILESDIR}/${PN}-4.1.1-FindLLVM.patch" - "${FILESDIR}/${PN}-4.1.1-numpy.patch" - "${FILESDIR}/${PN}-4.2.9-python3.12.patch" - "${FILESDIR}/${PN}-4.2.9-python3.13.patch" - "${FILESDIR}/${PN}-4.2.9-python3.12_1.patch" - "${FILESDIR}/${PN}-4.3.2-ffmpeg7.patch" - "${FILESDIR}/${PN}-4.3.2-openvdb-12.patch" - "${FILESDIR}/${PN}-4.3.2-optix-8.1.0.patch" - "${FILESDIR}/${PN}-4.3.2-system-glog.patch" - "${FILESDIR}/${PN}-4.4.0-optix-compile-flags.patch" -) - -blender_check_requirements() { - [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp - - if use doc; then - CHECKREQS_DISK_BUILD="4G" check-reqs_pkg_pretend - fi -} - -blender_get_version() { - if [[ -n "${BV}" && -n "${BVC}" ]]; then - return - fi - - local status - # Get blender version from blender itself. - # mirrors build_files/cmake/macros.cmake function(get_blender_version) - # NOTE maps x0y to x.y - # TODO this can potentially break for x > 9 and y > 9 - BV="$(grep "define BLENDER_VERSION " source/blender/blenkernel/BKE_blender_version.h | cut -d ' ' -f 3)" - status="$(pipestatus -v)" || die "fails to detect BLENDER_VERSION, (PIPESTATUS: ${status})" - BV="$(printf "%d.%d" "${BV:0: -2}" "${BV: -2}")" - - if [[ "${PV}" != 9999* && "${BLENDER_BRANCH}" != "${BV}" ]]; then - eerror "ebuild (${BLENDER_BRANCH}) and code (${BV}) version mismatch" - die "blender_get_version" - fi - - BVC="$(grep "define BLENDER_VERSION_CYCLE " source/blender/blenkernel/BKE_blender_version.h | cut -d ' ' -f 3)" - status="$(pipestatus -v)" || die "fails to detect BLENDER_VERSION_CYCLE, (PIPESTATUS: ${status})" -} - -pkg_pretend() { - blender_check_requirements -} - -pkg_setup() { - blender_check_requirements - python-single-r1_pkg_setup - - if use osl; then - llvm-r1_pkg_setup - fi -} - -src_unpack() { - if [[ "${PV}" == *9999* ]]; then - if ! use test; then - EGIT_SUBMODULES+=( '-tests/*' ) - fi - git-r3_src_unpack - else - default - - # BUG upstream returns LFS references instead of files - # if use test; then - # mkdir -p "${S}/tests/data/" || die - # mv blender-test-data/* "${S}/tests/data/" || die - # fi - fi -} - -src_prepare() { - use cuda && cuda_src_prepare - - cmake_src_prepare - - blender_get_version - - # Prepare icons and .desktop files for slotting. - sed \ - -e "s|blender.svg|blender-${BV}.svg|" \ - -e "s|blender-symbolic.svg|blender-${BV}-symbolic.svg|" \ - -e "s|blender.desktop|blender-${BV}.desktop|" \ - -e "s|org.blender.Blender.metainfo.xml|blender-${BV}.metainfo.xml|" \ - -i source/creator/CMakeLists.txt || die - - sed \ - -e "s|Name=Blender|Name=Blender ${BV}|" \ - -e "s|Exec=blender|Exec=blender-${BV}|" \ - -e "s|Icon=blender|Icon=blender-${BV}|" \ - -i release/freedesktop/blender.desktop || die - - sed \ - -e "/CMAKE_INSTALL_PREFIX_WITH_CONFIG/{s|\${CMAKE_INSTALL_PREFIX}|${T}\${CMAKE_INSTALL_PREFIX}|g}" \ - -i CMakeLists.txt \ - || die CMAKE_INSTALL_PREFIX_WITH_CONFIG - - mv \ - "release/freedesktop/icons/scalable/apps/blender.svg" \ - "release/freedesktop/icons/scalable/apps/blender-${BV}.svg" \ - || die - mv \ - "release/freedesktop/icons/symbolic/apps/blender-symbolic.svg" \ - "release/freedesktop/icons/symbolic/apps/blender-${BV}-symbolic.svg" \ - || die - mv \ - "release/freedesktop/blender.desktop" \ - "release/freedesktop/blender-${BV}.desktop" \ - || die - - mv \ - "release/freedesktop/org.blender.Blender.metainfo.xml" \ - "release/freedesktop/blender-${BV}.metainfo.xml" \ - || die - - sed \ - -e "s#\(set(cycles_kernel_runtime_lib_target_path \)\${cycles_kernel_runtime_lib_target_path}\(/lib)\)#\1\${CYCLES_INSTALL_PATH}\2#" \ - -i intern/cycles/kernel/CMakeLists.txt \ - || die - - if use hip; then - # fix hardcoded path - sed \ - -e "s#opt/rocm/hip/bin#$(hipconfig -p)/bin#g" \ - -i extern/hipew/src/hipew.c \ - || die - fi - - if use test; then - # Without this the tests will try to use /usr/bin/blender and /usr/share/blender/ to run the tests. - sed \ - -e "/string(REPLACE.*TEST_INSTALL_DIR/{s|\${CMAKE_INSTALL_PREFIX}|${T}\${CMAKE_INSTALL_PREFIX}|g}" \ - -i "build_files/cmake/testing.cmake" \ - || die "REPLACE.*TEST_INSTALL_DIR" - - # assertEquals was deprecated in Python-3.2 use assertEqual instead - sed \ - -e 's/assertEquals/assertEqual/g' \ - -i tests/python/bl_animation_action.py \ - || die - - sed -e '1i #include <cstdint>' -i extern/gtest/src/gtest-death-test.cc || die - else - cmake_comment_add_subdirectory tests - fi - - if [[ "${PV}" != *9999* ]]; then - rm "${WORKDIR}/blender-assets/publish/LICENSE" || die - fi - - if use vulkan; then - sed -e "s/extern_vulkan_memory_allocator/extern_vulkan_memory_allocator\nSPIRV-Tools-opt\nSPIRV-Tools\nSPIRV-Tools-link\nglslang\nSPIRV\nSPVRemapper/" -i source/blender/gpu/CMakeLists.txt || die - fi -} - -src_configure() { - # -Werror=odr, -Werror=lto-type-mismatch - # https://bugs.gentoo.org/859607 - # https://projects.blender.org/blender/blender/issues/120444 - filter-lto - - # Workaround for bug #922600 - append-ldflags "$(test-flags-CCLD -Wl,--undefined-version)" - - append-lfs-flags - blender_get_version - - local mycmakeargs=( - -DCMAKE_POLICY_DEFAULT_CMP0177="OLD" - - # we build a host-specific binary - -DWITH_INSTALL_PORTABLE="no" - -DWITH_CPU_CHECK="no" - - -DWITH_STRICT_BUILD_OPTIONS="yes" - -DWITH_LIBS_PRECOMPILED="no" - -DBUILD_SHARED_LIBS="no" # quadriflow only? - -DWITH_STATIC_LIBS=OFF - - -DPYTHON_INCLUDE_DIR="$(python_get_includedir)" - -DPYTHON_LIBRARY="$(python_get_library_path)" - -DPYTHON_VERSION="${EPYTHON/python/}" - -DWITH_ALEMBIC=$(usex alembic) - -DWITH_BOOST=yes - -DWITH_BULLET=$(usex bullet) - -DWITH_CODEC_FFMPEG=$(usex ffmpeg) - -DWITH_CODEC_SNDFILE=$(usex sndfile) - - -DWITH_CYCLES=$(usex cycles) - - -DWITH_CYCLES_DEVICE_CUDA=$(usex cuda) - -DWITH_CYCLES_CUDA_BINARIES="$(usex cuda $(usex cycles-bin-kernels))" - -DWITH_CYCLES_DEVICE_OPTIX=$(usex optix) - - -DWITH_CYCLES_DEVICE_HIP="$(usex hip)" - -DWITH_CYCLES_HIP_BINARIES=$(usex hip $(usex cycles-bin-kernels)) - - -DWITH_CYCLES_HYDRA_RENDER_DELEGATE="no" # TODO: package Hydra - -DWITH_CYCLES_EMBREE="$(usex embree)" - -DWITH_CYCLES_OSL=$(usex osl) - -DWITH_CYCLES_PATH_GUIDING=$(usex openpgl) - -DWITH_CYCLES_STANDALONE=no - -DWITH_CYCLES_STANDALONE_GUI=no - - -DWITH_DOC_MANPAGE=$(usex man) - -DWITH_DRACO="no" # TODO: Package Draco - -DWITH_FFTW3=$(usex fftw) - -DWITH_GHOST_WAYLAND=$(usex wayland) - -DWITH_GHOST_WAYLAND_DYNLOAD="no" - -DWITH_GHOST_X11=$(usex X) - -DWITH_GMP=$(usex gmp) - -DWITH_GTESTS=$(usex test) - -DWITH_HARFBUZZ="$(usex truetype)" - -DWITH_HARU=$(usex pdf) - -DWITH_HEADLESS="$(usex !X "$(usex !wayland)")" - -DWITH_HYDRA="no" # TODO: Package Hydra - -DWITH_IMAGE_OPENEXR=$(usex openexr) - -DWITH_IMAGE_OPENJPEG=$(usex jpeg2k) - -DWITH_IMAGE_WEBP=$(usex webp) - -DWITH_INPUT_NDOF=$(usex ndof) - -DWITH_INTERNATIONAL=$(usex nls) - -DWITH_JACK=$(usex jack) - -DWITH_MATERIALX="no" # TODO: Package MaterialX - -DWITH_MEM_JEMALLOC=$(usex jemalloc) - -DWITH_MEM_VALGRIND=$(usex valgrind) - -DWITH_MOD_FLUID=$(usex fluid) - -DWITH_MOD_OCEANSIM=$(usex fftw) - -DWITH_NANOVDB=$(usex nanovdb) - -DWITH_OPENAL=$(usex openal) - -DWITH_OPENCOLLADA=$(usex collada) - -DWITH_OPENCOLORIO=$(usex color-management) - -DWITH_OPENGL_BACKEND=$(usex opengl) - -DWITH_OPENIMAGEDENOISE=$(usex oidn) - -DWITH_OPENMP=$(usex openmp) - -DWITH_OPENSUBDIV=$(usex opensubdiv) - -DWITH_OPENVDB=$(usex openvdb) - -DWITH_OPENVDB_BLOSC=$(usex openvdb) - -DWITH_POTRACE=$(usex potrace) - -DWITH_PUGIXML=$(usex pugixml) - -DWITH_PULSEAUDIO=$(usex pulseaudio) - -DWITH_PYTHON_INSTALL=no - -DWITH_PYTHON_INSTALL_NUMPY=no - -DWITH_PYTHON_INSTALL_ZSTANDARD=no - -DWITH_RENDERDOC="$(usex renderdoc)" - -DWITH_SDL=$(usex sdl) - -DWITH_SYSTEM_BULLET="yes" - -DWITH_SYSTEM_EIGEN3=yes - -DWITH_SYSTEM_FREETYPE=yes - -DWITH_SYSTEM_GFLAGS="yes" - -DWITH_SYSTEM_GLOG="yes" - -DWITH_SYSTEM_LZO=yes - -DWITH_TBB=$(usex tbb) - -DWITH_USD="no" # TODO: Package USD - -DWITH_XR_OPENXR=no - -DWITH_UNITY_BUILD="no" - ) - - if has_version ">=dev-python/numpy-2"; then - mycmakeargs+=( - -DPYTHON_NUMPY_INCLUDE_DIRS="$(python_get_sitedir)/numpy/_core/include" - -DPYTHON_NUMPY_PATH="$(python_get_sitedir)/numpy/_core/include" - ) - fi - - # requires dev-vcs/git - if [[ "${PV}" == *9999* && "${BVC}" == "alpha" ]]; then - mycmakeargs+=( - # -DWITH_BUILDINFO="no" - -DWITH_EXPERIMENTAL_FEATURES="$(usex experimental)" - ) - else - mycmakeargs+=( - -DWITH_EXPERIMENTAL_FEATURES="no" - ) - fi - - if use cuda; then - # Ease compiling with required gcc similar to cuda_sanitize but for cmake - if use cycles-bin-kernels; then - local -x CUDAHOSTCXX="$(cuda_gccdir)" - local -x CUDAHOSTLD="$(tc-getCXX)" - - if [[ -n "${CUDAARCHS}" ]]; then - mycmakeargs+=( - -DCYCLES_CUDA_BINARIES_ARCH="$(echo "${CUDAARCHS}" | sed -e 's/^/sm_/g' -e 's/;/;sm_/g')" - ) - fi - fi - fi - - if use hip; then - mycmakeargs+=( - -DHIP_ROOT_DIR="$(hipconfig -p)" - -DHIP_HIPCC_FLAGS="-fcf-protection=none" - -DCMAKE_HIP_LINK_EXECUTABLE="$(get_llvm_prefix)/bin/clang++" - -DCYCLES_HIP_BINARIES_ARCH="$(get_amdgpu_flags)" - ) - fi - - if use optix; then - mycmakeargs+=( - -DCYCLES_RUNTIME_OPTIX_ROOT_DIR="${ESYSROOT}/opt/optix" - -DOPTIX_ROOT_DIR="${ESYSROOT}/opt/optix" - ) - fi - - if use wayland; then - mycmakeargs+=( - -DWITH_GHOST_WAYLAND_APP_ID="blender-${BV}" - -DWITH_GHOST_WAYLAND_LIBDECOR="$(usex gnome)" - ) - fi - - # This is currently needed on arm64 to get the NEON SIMD wrapper to compile the code successfully - use arm64 && append-flags -flax-vector-conversions - - append-cflags "$(usex debug '-DDEBUG' '-DNDEBUG')" - append-cxxflags "$(usex debug '-DDEBUG' '-DNDEBUG')" - - if tc-is-gcc; then - # We disable these to respect the user's choice of linker. - mycmakeargs+=( - -DWITH_LINKER_GOLD=no - ) - fi - - if tc-is-clang || use osl; then - mycmakeargs+=( - -DWITH_CLANG=yes - -DWITH_LLVM=yes - ) - fi - - if use test; then - local CYCLES_TEST_DEVICES=( "CPU" ) - if use cycles-bin-kernels; then - use cuda && CYCLES_TEST_DEVICES+=( "CUDA" ) - use optix && CYCLES_TEST_DEVICES+=( "OPTIX" ) - use hip && CYCLES_TEST_DEVICES+=( "HIP" ) - fi - mycmakeargs+=( - -DCMAKE_INSTALL_PREFIX_WITH_CONFIG="${T}/usr" - -DCYCLES_TEST_DEVICES="$(local IFS=";"; echo "${CYCLES_TEST_DEVICES[*]}")" - ) - - # NOTE in lieu of a FEATURE/build_options - if [[ "${EXPENSIVE_TESTS:-0}" -gt 0 ]]; then - mycmakeargs+=( - -DWITH_COMPOSITOR_REALTIME_TESTS="yes" - - -DWITH_CYCLES_TEST_OSL="$(usex osl)" - - -DWITH_GPU_DRAW_TESTS="yes" - - -DWITH_GPU_RENDER_TESTS="yes" - -DWITH_GPU_RENDER_TESTS_SILENT="no" - ) - - if [[ "${PV}" == *9999* && "${BVC}" == "alpha" ]] && use experimental; then - mycmakeargs+=( - # Enable user-interface tests using a headless display server. - # Currently this depends on WITH_GHOST_WAYLAND and the weston compositor (Experimental) - -DWITH_UI_TESTS="$(usex wayland)" - -DWESTON_BIN="${ESYSROOT}/usr/bin/weston" - ) - fi - else - mycmakeargs+=( - -DWITH_GPU_RENDER_TESTS="no" - ) - fi - fi - - cmake_src_configure -} - -src_test() { - # A lot of tests need to have access to the installed data files. - # So install them into the image directory now. - DESTDIR="${T}" cmake_build install - - blender_get_version - # Define custom blender data/script file paths, or we won't be able to find them otherwise during testing. - # (Because the data is in the image directory and it will default to look in /usr/share) - local -x BLENDER_SYSTEM_RESOURCES="${T%/}/usr/share/blender/${BV}" - - # Sanity check that the script and datafile path is valid. - # If they are not valid, blender will fallback to the default path which is not what we want. - [[ -d "${BLENDER_SYSTEM_RESOURCES}" ]] || die "The custom resources path is invalid, fix the ebuild!" - - # TODO only picks first card - addwrite "/dev/dri/card0" - addwrite "/dev/dri/renderD128" - addwrite "/dev/udmabuf" - - if use cuda; then - cuda_add_sandbox -w - addwrite "/dev/char/" - fi - - if ! has_version "media-libs/openusd"; then - CMAKE_SKIP_TESTS+=( - # from pxr import Usd # ModuleNotFoundError: No module named 'pxr' - "^script_bundled_modules$" - ) - fi - - # For debugging, print out all information. - local -x VERBOSE="$(usex debug "true" "false")" - - # Show the window in the foreground. - local -x USE_WINDOW="false" - local -x USE_DEBUG="false" - - if [[ "${EXPENSIVE_TESTS:-0}" -gt 0 ]]; then - if [[ "${USE_WINDOW}" = "true" ]] && - [[ "${PV}" == *9999* && "${BVC}" == "alpha" ]] && - use experimental && use wayland; then - # This runs weston - xdg_environment_reset - fi - - if [[ "${USE_WINDOW}" == "true" ]]; then - xdg_environment_reset - # WITH_GPU_RENDER_TESTS_HEADED - if use wayland; then - local compositor exit_code - local logfile=${T}/weston.log - weston --xwayland --backend=headless --socket=wayland-5 --idle-time=0 2>"${logfile}" & - compositor=$! - local -x WAYLAND_DISPLAY=wayland-5 - sleep 1 # wait for xwayland to be up - local -x DISPLAY="$(grep "xserver listening on display" "${logfile}" | cut -d ' ' -f 5)" - - cmake_src_test - - exit_code=$? - kill "${compositor}" - elif use X; then - virtx cmake_src_test - fi - fi - else - cmake_src_test - fi - - # Clean up the image directory for src_install - rm -fr "${T}/usr" || die -} - -src_install() { - blender_get_version - - # Pax mark blender for hardened support. - pax-mark m "${BUILD_DIR}"/bin/blender - - cmake_src_install - - # X-KDE-RunOnDiscreteGpu is obsolete, so trim it - sed \ - -e "/X-KDE-RunOnDiscreteGpu.*/d" \ - -i "${ED}/usr/share/applications/blender-${BV}.desktop" || die - - if use man; then - # Slot the man page - mv "${ED}/usr/share/man/man1/blender.1" "${ED}/usr/share/man/man1/blender-${BV}.1" || die - fi - - if use doc; then - # Define custom blender data/script file paths. Otherwise Blender will not be able to find them during doc building. - # (Because the data is in the image directory and it will default to look in /usr/share) - local -x BLENDER_SYSTEM_RESOURCES="${ED}/usr/share/blender/${BV}" - - # Workaround for binary drivers. - addpredict /dev/ati - addpredict /dev/dri - addpredict /dev/nvidiactl - - einfo "Generating Blender C/C++ API docs ..." - cd "${CMAKE_USE_DIR}"/doc/doxygen || die - doxygen -u Doxyfile || die - doxygen || die "doxygen failed to build API docs." - - cd "${CMAKE_USE_DIR}" || die - einfo "Generating (BPY) Blender Python API docs ..." - "${BUILD_DIR}"/bin/blender --background --python doc/python_api/sphinx_doc_gen.py -noaudio || die "sphinx failed." - - cd "${CMAKE_USE_DIR}"/doc/python_api || die - sphinx-build sphinx-in BPY_API || die "sphinx failed." - - docinto "html/API/python" - dodoc -r "${CMAKE_USE_DIR}"/doc/python_api/BPY_API/. - - docinto "html/API/blender" - dodoc -r "${CMAKE_USE_DIR}"/doc/doxygen/html/. - fi - - if [[ "${PV}" != *9999* ]]; then - insinto "/usr/share/blender/${BV}/datafiles/assets" - doins -r "${WORKDIR}/blender-assets/publish/"* - fi - - # Fix doc installdir - docinto html - dodoc "${CMAKE_USE_DIR}"/release/text/readme.html - rm -r "${ED}"/usr/share/doc/blender || die - - python_optimize "${ED}/usr/share/blender/${BV}/scripts" - - mv "${ED}/usr/bin/blender-thumbnailer" "${ED}/usr/bin/blender-${BV}-thumbnailer" \ - || die "blender-thumbnailer version rename failed" - mv "${ED}/usr/bin/blender" "${ED}/usr/bin/blender-${BV}" || die "blender version rename failed" -} - -pkg_postinst() { - elog - elog "Blender uses python integration. As such, may have some" - elog "inherent risks with running unknown python scripts." - elog - elog "It is recommended to change your blender temp directory" - elog "from /tmp to /home/user/tmp or another tmp file under your" - elog "home directory. This can be done by starting blender, then" - elog "changing the 'Temporary Files' directory in Blender preferences." - elog - - if use osl && ! has_version "media-libs/mesa[${LLVM_USEDEP}]"; then - ewarn "" - ewarn "OSL is know to cause runtime segfaults if Mesa has been linked to" - ewarn "an other LLVM version than what OSL is linked to." - ewarn "See https://bugs.gentoo.org/880671 for more details" - ewarn "" - fi - - # NOTE build_files/cmake/Modules/FindPythonLibsUnix.cmake: set(_PYTHON_VERSION_SUPPORTED 3.11) - if ! use python_single_target_python3_11; then - elog "You are building Blender with a newer python version than" - elog "supported by this version upstream." - elog "If you experience breakages with e.g. plugins, please switch to" - elog "PYTHON_SINGLE_TARGET: python3_11 instead." - elog "Bug: https://bugs.gentoo.org/737388" - elog - fi - - xdg_icon_cache_update - xdg_mimeinfo_database_update - xdg_desktop_database_update -} - -pkg_postrm() { - xdg_icon_cache_update - xdg_mimeinfo_database_update - xdg_desktop_database_update - - if [[ -z "${REPLACED_BY_VERSION}" ]]; then - ewarn - ewarn "You may want to remove the following directories" - ewarn "- ~/.config/${PN}/${BV}/cache/" - ewarn "- ~/.cache/cycles/" - ewarn "It may contain extra render kernels not tracked by portage" - ewarn - fi -} diff --git a/media-gfx/blender/files/blender-4.2.9-python3.12.patch b/media-gfx/blender/files/blender-4.2.9-python3.12.patch deleted file mode 100644 index 94d0875cf67d..000000000000 --- a/media-gfx/blender/files/blender-4.2.9-python3.12.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 1865de1c738a1a1ead520fbd38487815e13906e9 Mon Sep 17 00:00:00 2001 -From: Campbell Barton <[email protected]> -Date: Thu, 28 Nov 2024 12:04:45 +1100 -Subject: [PATCH] Fix #129926: Crash with Python 3.12 & Manta flow - -Python 3.12 no longer supports calls to PyImport_AppendInittab -once initialized. - -The call was redundant as Blender's `bpy_internal_modules` already -includes the "manta" module. - -Resolve by disabling the call when Python's lifecycle isn't being -managed by manta-flow. ---- - extern/mantaflow/helper/pwrapper/registry.cpp | 19 ++++++++++++++----- - 1 file changed, 14 insertions(+), 5 deletions(-) - -diff --git a/extern/mantaflow/helper/pwrapper/registry.cpp b/extern/mantaflow/helper/pwrapper/registry.cpp -index b4206a41dea..3ad7475d0e3 100644 ---- a/extern/mantaflow/helper/pwrapper/registry.cpp -+++ b/extern/mantaflow/helper/pwrapper/registry.cpp -@@ -112,7 +112,7 @@ class WrapperRegistry { - const std::string &name, - Manta::PbArgs &args, - Manta::PbClass *parent); -- void construct(const std::string &scriptname, const vector<string> &args); -+ void construct(bool python_lifecycle, const std::string &scriptname, const vector<string> &args); - void cleanup(); - void renameObjects(); - void runPreInit(PyObject *name_space); -@@ -566,7 +566,9 @@ PyObject *WrapperRegistry::createPyObject(const string &classname, - } - - // prepare typeinfo and register python module --void WrapperRegistry::construct(const string &scriptname, const vector<string> &args) -+void WrapperRegistry::construct(const bool python_lifecycle, -+ const string &scriptname, -+ const vector<string> &args) - { - mScriptName = scriptname; - this->args = args; -@@ -575,8 +577,15 @@ void WrapperRegistry::construct(const string &scriptname, const vector<string> & - registerMeta(); - registerDummyTypes(); - -- // work around for certain gcc versions, cast to char* -- PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_manta_main); -+ // Don't extend the init-tab when Python is already initialized. -+ // Since Python 3.12 this isn't supported and will crash. -+ // -+ // When `python_lifecycle` is false (when manta-flow is embedded), it's the responsibility -+ // of the application embedding this code to include #PyInit_manta_main in the init-tab. -+ if (python_lifecycle) { -+ // work around for certain gcc versions, cast to char* -+ PyImport_AppendInittab((char *)gDefaultModuleName.c_str(), PyInit_manta_main); -+ } - } - - inline PyObject *castPy(PyTypeObject *p) -@@ -711,7 +720,7 @@ void setup(const bool python_lifecycle, - const std::vector<std::string> &args, - PyObject *name_space) - { -- WrapperRegistry::instance().construct(filename, args); -+ WrapperRegistry::instance().construct(python_lifecycle, filename, args); - if (python_lifecycle) { - Py_Initialize(); - } diff --git a/media-gfx/blender/files/blender-4.2.9-python3.12_1.patch b/media-gfx/blender/files/blender-4.2.9-python3.12_1.patch deleted file mode 100644 index 0312e786861c..000000000000 --- a/media-gfx/blender/files/blender-4.2.9-python3.12_1.patch +++ /dev/null @@ -1,39 +0,0 @@ -From f60f2b769b1d43d253d470c99f8555e90cb45fd9 Mon Sep 17 00:00:00 2001 -From: Campbell Barton <[email protected]> -Date: Mon, 21 Oct 2024 20:45:35 +1100 -Subject: [PATCH] Unbreak building with Python 3.12 - -Support for 3.13 [0] broke 3.12. - -[0]: d9f38fca5ffe29136cd6f390e318ad8455864582 ---- - source/blender/python/generic/py_capi_utils.cc | 2 +- - source/blender/python/generic/py_capi_utils.hh | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/source/blender/python/generic/py_capi_utils.cc b/source/blender/python/generic/py_capi_utils.cc -index 74c829d717e..d6c58a5c6eb 100644 ---- a/source/blender/python/generic/py_capi_utils.cc -+++ b/source/blender/python/generic/py_capi_utils.cc -@@ -39,7 +39,7 @@ - # include "BLI_math_base.h" /* isfinite() */ - #endif - --#if PY_VERSION_HEX <= 0x030c0000 /* <=3.12 */ -+#if PY_VERSION_HEX < 0x030d0000 /* <3.13 */ - # define PyLong_AsInt _PyLong_AsInt - # define PyUnicode_CompareWithASCIIString _PyUnicode_EqualToASCIIString - #endif -diff --git a/source/blender/python/generic/py_capi_utils.hh b/source/blender/python/generic/py_capi_utils.hh -index 81740e0d0ad..29222d35c2c 100644 ---- a/source/blender/python/generic/py_capi_utils.hh -+++ b/source/blender/python/generic/py_capi_utils.hh -@@ -339,7 +339,7 @@ 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 */ -+#if PY_VERSION_HEX < 0x030d0000 /* <3.13 */ - return (int32_t)_PyLong_AsInt(value); - #else - return (int32_t)PyLong_AsInt(value); diff --git a/media-gfx/blender/files/blender-4.2.9-python3.13.patch b/media-gfx/blender/files/blender-4.2.9-python3.13.patch deleted file mode 100644 index 0dd6f4b95b4d..000000000000 --- a/media-gfx/blender/files/blender-4.2.9-python3.13.patch +++ /dev/null @@ -1,626 +0,0 @@ -From d9f38fca5ffe29136cd6f390e318ad8455864582 Mon Sep 17 00:00:00 2001 -From: Campbell Barton <[email protected]> -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 <opcode.h> - #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 <internal/pycore_code.h> -+#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);
