blender: verify expected Python version during build

Upstream builds and tests with a specific Python version. Further, the
Blender addon ecosystem generally expects that version to be used, so
ensure that the correct version is used when upstream changes. Python
often makes backwards-incompatible changes in “minor” releases.

To quote upstream source code:

> Blender only supports a single Python version at the moment.

Perform the check during preConfigure since we can check it then and so
it avoids wasting time configuring+building and then failing.
This commit is contained in:
Andrew Marshall 2024-07-11 10:02:00 -04:00
parent 36b9ee7188
commit 36757e284c

View File

@ -198,6 +198,17 @@ stdenv.mkDerivation (finalAttrs: {
"-DWITH_CYCLES_DEVICE_OPTIX=ON"
];
preConfigure = ''
(
expected_python_version=$(grep -E --only-matching 'set\(_PYTHON_VERSION_SUPPORTED [0-9.]+\)' build_files/cmake/Modules/FindPythonLibsUnix.cmake | grep -E --only-matching '[0-9.]+')
actual_python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[0:2])))')
if ! [[ "$actual_python_version" = "$expected_python_version" ]]; then
echo "wrong Python version, expected '$expected_python_version', got '$actual_python_version'" >&2
exit 1
fi
)
'';
nativeBuildInputs =
[
cmake