Page MenuHome

blender 2.91.2 fails to build with python 3.10a5 (upcoming python 3.10)
Closed, ResolvedPublic

Description

With coming python 3.10 (currently python 3.10a5), blender 2.91.2 fails to compile:

gmake[2]: Entering directory '/builddir/build/BUILD/blender-2.91.2/x86_64-redhat-linux-gnu'
[ 74%] Building C object source/blender/python/intern/CMakeFiles/bf_python.dir/bpy.c.o
cd /builddir/build/BUILD/blender-2.91.2/x86_64-redhat-linux-gnu/source/blender/python/intern && /usr/bin/gcc -DBUILD_DATE -DNDEBUG -DWITH_ALEMBIC -DWITH_ASSERT_ABORT -DWITH_AUDASPACE -DWITH_AVI -DWITH_BULLET -DWITH_CINEON -DWITH_COLLADA -DWITH_COMPOSITOR -DWITH_CYCLES -DWITH_CYCLES_EMBREE -DWITH_DDS -DWITH_FLUID -DWITH_FREESTYLE -DWITH_HDR -DWITH_INPUT_NDOF -DWITH_INTERNATIONAL -DWITH_JACK -DWITH_LIBMV -DWITH_MOD_REMESH -DWITH_OCEANSIM -DWITH_OCIO -DWITH_OPENAL -DWITH_OPENEXR -DWITH_OPENGL -DWITH_OPENIMAGEIO -DWITH_OPENJPEG -DWITH_OPENSUBDIV -DWITH_OPENVDB -DWITH_POTRACE -DWITH_SDL -DWITH_SNDFILE -DWITH_TIFF -DWITH_XR_OPENXR -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D__LITTLE_ENDIAN__ -D__MMX__ -D__SSE2__ -D__SSE__ -I/builddir/build/BUILD/blender-2.91.2/source/blender/python -I/builddir/build/BUILD/blender-2.91.2/source/blender/blenkernel -I/builddir/build/BUILD/blender-2.91.2/source/blender/blenlib -I/builddir/build/BUILD/blender-2.91.2/source/blender/blenloader -I/builddir/build/BUILD/blender-2.91.2/source/blender/blentranslation -I/builddir/build/BUILD/blender-2.91.2/source/blender/depsgraph -I/builddir/build/BUILD/blender-2.91.2/source/blender/editors/include -I/builddir/build/BUILD/blender-2.91.2/source/blender/gpu -I/builddir/build/BUILD/blender-2.91.2/source/blender/imbuf -I/builddir/build/BUILD/blender-2.91.2/source/blender/makesdna -I/builddir/build/BUILD/blender-2.91.2/source/blender/makesrna -I/builddir/build/BUILD/blender-2.91.2/source/blender/windowmanager -I/builddir/build/BUILD/blender-2.91.2/intern/clog -I/builddir/build/BUILD/blender-2.91.2/intern/guardedalloc -I/builddir/build/BUILD/blender-2.91.2/intern/mantaflow/extern -I/builddir/build/BUILD/blender-2.91.2/intern/opencolorio -I/builddir/build/BUILD/blender-2.91.2/intern/cycles/blender -I/builddir/build/BUILD/blender-2.91.2/source/blender/freestyle/intern/python -I/builddir/build/BUILD/blender-2.91.2/intern/openvdb -I/builddir/build/BUILD/blender-2.91.2/source/blender/io/alembic -I/builddir/build/BUILD/blender-2.91.2/source/blender/imbuf/intern/oiio -I/builddir/build/BUILD/blender-2.91.2/intern/opensubdiv -isystem /usr/include/python3.10 -isystem /usr/include/SDL2 -Wall -Wcast-align -Werror=implicit-function-declaration -Werror=return-type -Werror=vla -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -Wno-unknown-pragmas -Wpointer-arith -Wunused-parameter -Wwrite-strings -Wlogical-op -Wundef -Winit-self -Wmissing-include-dirs -Wno-div-by-zero -Wtype-limits -Wformat-signedness -Wrestrict -Wnonnull -Wabsolute-value -Wuninitialized -Wredundant-decls -Wshadow -Wno-error=unused-but-set-variable -Wimplicit-fallthrough=5 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wl,--as-needed -fuse-ld=gold -fopenmp -std=gnu11   -msse -pipe -fPIC -funsigned-char -fno-strict-aliasing -msse2 -Wno-maybe-uninitialized -DNDEBUG -o CMakeFiles/bf_python.dir/bpy.c.o -c /builddir/build/BUILD/blender-2.91.2/source/blender/python/intern/bpy.c
/builddir/build/BUILD/blender-2.91.2/source/blender/python/intern/bpy.c: In function 'bpy_escape_identifier':
/builddir/build/BUILD/blender-2.91.2/source/blender/python/intern/bpy.c:271:15: error: implicit declaration of function '_PyUnicode_AsStringAndSize'; did you mean 'PyUnicode_FromStringAndSize'? [-Werror=implicit-function-declaration]
  271 |   value_str = _PyUnicode_AsStringAndSize(value, &value_str_len);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |               PyUnicode_FromStringAndSize
/builddir/build/BUILD/blender-2.91.2/source/blender/python/intern/bpy.c:271:13: warning: assignment to 'const char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  271 |   value_str = _PyUnicode_AsStringAndSize(value, &value_str_len);
      |             ^
cc1: some warnings being treated as errors

System Information
Operating system:
Fedora 34 x86_64
gcc-11.0.0-0.18.fc34.x86_64
python3-3.10.0~a5-1.fc34.x86_64

Graphics card:

Blender Version
Broken: at least 2.91.2

Note
_PyUnicode_AsStringAndSize is removed from Include/cpython/unicodeobject.h with this commit:
https://github.com/python/cpython/commit/3a8fdb28794b2f19f6c8464378fb8b46bce1f5f4#diff-6be7f081fe6c5e9cbc89323a00399b291d1cda855bcb4c6eeaee0fac89c2f8dd

As _PyUnicode_AsStringAndSize had been just the alias of PyUnicode_AsUTF8AndSize and PyUnicode_AsUTF8AndSize will be available even on python3.10 and later, I think replacing as such is enough.

Event Timeline

Note that _PyUnicode_AsStringAndSize appears on:

$ grep -rl _PyUnicode_AsStringAndSize blender-2.91.2/
blender-2.91.2/source/blender/python/generic/py_capi_utils.c
blender-2.91.2/source/blender/python/generic/idprop_py_api.c
blender-2.91.2/source/blender/python/generic/imbuf_py_api.c
blender-2.91.2/source/blender/python/gpu/gpu_py_vertex_format.c
blender-2.91.2/source/blender/python/gpu/gpu_py_shader.c
blender-2.91.2/source/blender/python/gpu/gpu_py_api.c
blender-2.91.2/source/blender/python/intern/bpy_props.c
blender-2.91.2/source/blender/python/intern/bpy.c
blender-2.91.2/source/blender/python/intern/bpy_rna.c
blender-2.91.2/source/blender/python/mathutils/mathutils_Matrix.c

Hello, just for my curiosity, isn't Blender 2.92 as well as 2.93 based on Python 3.7.7? Why are you compiling for Python 10, not yet officially supported for the Blender development? I read there are plans to move to Python 3.9 but that's all I know about. I repeat it, just for my curiosity. Thank you.

It is because Fedora 33 already uses python 3.9, Fedora 34 will use python 3.9, and Fedora 35 (to be released on 2021/Oct) will use python 3.10 (also to be released on 2021/Oct) . Then we and python maintainers on Fedora Project are preparing for python 3.10 beforehand to ensure that we can switch to python 3.10 smoothly:

https://fedoraproject.org/wiki/Changes/Python3.10

Thank you for the explanation.

Update, Blender now runs with Python 3.10 (previously it compiled but started with errors: ref rB08dbc4f996e4: PyAPI: use postponed annotations to support Python 3.10)