Page MenuHome

cmake/deps: Update python to 3.9.1
ClosedPublic

Authored by Ray Molenkamp (LazyDodo) on Jan 30 2021, 3:45 AM.

Details

Summary

The following packages also have received updates in this update

IDNA 2.10
CHARDET 4.0.0
URLLIB3 1.26.3
CERTIFI 2020.12.5
REQUESTS 2.25.1
NUMPY 1.19.5

numpy has gained a hard dependency on cython

CYTHON 0.29.21

Diff Detail

Repository
rB Blender
Branch
T (branched from master)
Build Status
Buildable 12539
Build 12539: arc lint + arc unit

Event Timeline

Ray Molenkamp (LazyDodo) requested review of this revision.Jan 30 2021, 3:45 AM
Ray Molenkamp (LazyDodo) created this revision.

The version changes are fine with me, I'll leave it to the platform maintainers and Python module to do the actual review.

Campbell Barton (campbellbarton) requested changes to this revision.EditedFeb 2 2021, 7:11 AM
  • This fails to build on Linux as build_files/build_environment/patches/python_linux.diff needs to be updated, attached is an updated patch: P1937
  • After applying this patch I'm not getting the Python in ${LIBDIR}/python/bin, instead the directory is empty (looking into this).

The following files should be updated to reference Python 3.9.

  • build_files/cmake/platform/platform_win32.cmake
  • build_files/cmake/Modules/FindPythonLibsUnix.cmake

There are other version checks in:

  • CMakeLists.txt
  • python/intern/bpy_capi_utils.h

Once 3.7x support is dropped, these need to be changed, as well as around 160 if PY_VERSION_HEX >= 0x03080000 checks in our PyTypeObject definitions, these need not be part of this patch though.

This revision now requires changes to proceed.Feb 2 2021, 7:11 AM

Updated the linux patch to apply to Python 3.9

  • Remove macOS patch for arm64 support (now part of Python 3.9x)

This fails to build on Linux as build_files/build_environment/patches/python_linux.diff needs to be updated, attached is an updated patch: P1937
After applying this patch I'm not getting the Python in ${LIBDIR}/python/bin, instead the directory is empty (looking into this).

You could have left the linux changes for sybren (but i'm pretty sure he'll appreciate you stepping in). I generally build and test extensively on windows, anything beyond that is best effort I usually (but not this time) take a quick stab at linux but the linux maintainers are both faster and better at maintaining their platform. Once all platform maintainers are happy with a diff, the diff can land and svn libs can be build.

The following files should be updated to reference Python 3.9.

build_files/cmake/platform/platform_win32.cmake
build_files/cmake/Modules/FindPythonLibsUnix.cmake

When this diff lands the libs will not be in SVN and this can take several days depending on the load of the platform dev in question, so that'll cause build errors if you change that early, the changes in build_files/cmake/platform/platform_win32.cmake will be made on the day I add the libs to svn and should not be part of this diff.

@Ray Molenkamp (LazyDodo) thanks, I assumed some of the changes were avoided to account for the delay in building new libs.

Found the issue with Python not being copied - Python removed the 'm' character from their ABI flags, see: https://github.com/python/cpython/commit/3fde750cc4e4057076650a92946ec1d492464799

Updated the harvest command for changed ABI flag in Python 3.9

This revision is now accepted and ready to land.Feb 2 2021, 10:05 PM

Accidentally included Mesa changes.

You could have left the linux changes for sybren (but i'm pretty sure he'll appreciate you stepping in).

I certainly appreciate it, thanks @Campbell Barton (campbellbarton) .

The patch works fine for building Python 3.9.1 on CentOS. With a version number bump in platform_unix.cmake, Blender builds against it. However, it doesn't run without a ninja install step:

> blender spring_pose_facials.blend
Read prefs: /home/sybren/.config/blender/2.93/config/userpref.blend
Python path configuration:
  PYTHONHOME = '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python'
  PYTHONPATH = (not set)
  program name = '/home/sybren/workspace/blender-git/build_linux/bin/blender'
  isolated = 0
  environment = 0
  user site = 0
  import site = 1
  sys._base_executable = '/home/sybren/workspace/blender-git/build_linux/bin/blender'
  sys.base_prefix = '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python'
  sys.base_exec_prefix = '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python'
  sys.platlibdir = 'lib'
  sys.executable = '/home/sybren/workspace/blender-git/build_linux/bin/blender'
  sys.prefix = '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python'
  sys.exec_prefix = '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python'
  sys.path = [
    '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python/lib/python39.zip',
    '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python/lib/python3.9',
    '/home/sybren/workspace/blender-git/build_linux/bin/2.93/python/lib/python3.9/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f961dab0080 (most recent call first):
<no Python frame>

I usually run Blender without install step; I just have a symlink bin/2.93../../blender/release and that worked fine until now. When I switch back to Python 3.7 (in platform_unix.cmake) things work fine in that setup again.

Does anyone know what could be the cause of this?

I have been running with Python 3.9 for months without an install step.

It could be that Python isn't installed on your OS, where previously it was picking up the system's Python.

It was indeed a local issue, thanks for the pointer (not exactly that, but it did make me look in the right direction).

When this diff lands the libs will not be in SVN and this can take several days depending on the load of the platform dev in question, so that'll cause build errors if you change that early, the changes in build_files/cmake/platform/platform_win32.cmake will be made on the day I add the libs to svn and should not be part of this diff.

This also applies to the required changes to FindPythonLibsUnix.cmake.

We could just add Python 3.9 to the SVN repository, then commit the changes required to make Blender actually use it, and only after this has been commited for all the platforms, remove Python 3.7. Although it's a bit more cumbersome to do, it should avoid breakage. It would also give a revision in SVN that could be used for bisecting Blender across this library upgrade. What do you guys think?

We could just add Python 3.9 to the SVN repository, then commit the changes required to make Blender actually use it, and only after this has been commited for all the platforms, remove Python 3.7. Although it's a bit more cumbersome to do, it should avoid breakage. It would also give a revision in SVN that could be used for bisecting Blender across this library upgrade. What do you guys think?

Sounds good, for bisecting you have to go back quite far before Python 3.9x stops working (some thousands of revisions IIRC), I've rarely needed to go back this far, although I have a local build of older python for doing more historic stuff.

Just a note that I also switched Numpy to pip on install_deps.sh, seems to work perfectly (and saves quiet a lot of hassles).

Not sure how possible that would be for the CMake-based system?

Give pip a whirl for numpy, it's somehow mixing 32 bit compilers and 64 bit libs naturally leading to linker errors, i'd prefer to keep it building externally for now

Sebastián Barschkis (sebbas) requested changes to this revision.Feb 9 2021, 12:19 PM

For macOS we need a version bump and m flag adjustment in build_files/cmake/platform/platform_apple.cmake (lines 134-140).

This revision now requires changes to proceed.Feb 9 2021, 12:19 PM

@Sebastián Barschkis (sebbas) this bump will be done when the new libraries are built and uploaded.

I see, in that case all good! The import numpy (D10368) fix can come later.

This revision is now accepted and ready to land.Feb 9 2021, 2:00 PM