From 36b9ee7188197be35099bece775351e24298bf65 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 9 Jul 2024 23:42:38 -0400 Subject: [PATCH 1/2] blender: use correct Python version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This partially reverts commit 46861969d7e56eb98451d8a270b160c7cbbb37ea. Using nixpkgs’s default Python was previously necessary to workaround a problem that no longer exists: materialx always using the top-level python3 instead of that which matches its dependents. Using the same Python version as the upstream Blender release is desired to ensure compatibility not only Blender itself but with the addon ecosystem. Also move the selection of non-nixpkgs-default Python to all-packages rather than the pkg’s function args as that is the current preference (as documented in ./pkgs/by-name/README.md#changing-implicit-attribute-defaults). --- pkgs/top-level/all-packages.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 06f85d5b605a..a7413bf53321 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29582,6 +29582,7 @@ with pkgs; blender = callPackage ../applications/misc/blender { openexr = openexr_3; + python3Packages = python311Packages; inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics ForceFeedback OpenAL OpenGL; }; From 36757e284c9ab817f7b70efe9f78ec630aee8862 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 11 Jul 2024 10:02:00 -0400 Subject: [PATCH 2/2] blender: verify expected Python version during build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- pkgs/applications/misc/blender/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index bb5a0b660086..fdebd48b4102 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -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