[Bf-blender-cvs] [30ac801345a] temp-usd-export-unittest: Tests runner: use Python from install dir, and break if not found

Sybren A. Stüvel noreply at git.blender.org
Fri Apr 10 11:11:43 CEST 2020


Commit: 30ac801345a905a79c5341430c787acf84b3c0d7
Author: Sybren A. Stüvel
Date:   Fri Apr 10 11:11:41 2020 +0200
Branches: temp-usd-export-unittest
https://developer.blender.org/rB30ac801345a905a79c5341430c787acf84b3c0d7

Tests runner: use Python from install dir, and break if not found

===================================================================

M	tests/CMakeLists.txt

===================================================================

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index acd3f6ba18f..18123da22bd 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -21,17 +21,27 @@ elseif(APPLE)
 else()
   set(TEST_BLENDER_EXE ${TEST_INSTALL_DIR}/blender)
 
-  if(EXISTS ${PYTHON_EXECUTABLE})
-    message(STATUS "Using Python from PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
-    set(TEST_PYTHON_EXE ${PYTHON_EXECUTABLE})
+  # Search for the Python executable to use in the tests.
+  # The installation directory's Python is the best one to use. However, it can only be there after the install step, which means
+  # that Python will never be here on a fresh system. This is why the search continues to the pre-built libraries, and if that
+  # doesn't exist either, default to whatever Python CMake found.
+  set(_python_exe "${TEST_INSTALL_DIR}/${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}/python/bin/python${PYTHON_VERSION}m")
+  if(EXISTS ${_python_exe})
+    message(STATUS "Tests: Using Python from installation directory: ${_python_exe}")
+    set(TEST_PYTHON_EXE ${_python_exe})
   else()
     set(_python_exe "${LIBDIR}/python/bin/python${PYTHON_VERSION}m")
     if(EXISTS ${_python_exe})
-      message(STATUS "Using Python from pre-compiled LIBDIR: ${_python_exe}")
+      message(STATUS "Tests: Using Python from pre-compiled LIBDIR: ${_python_exe}")
       set(TEST_PYTHON_EXE ${_python_exe})
+    elseif(EXISTS ${PYTHON_EXECUTABLE})
+      message(STATUS "Tests: Using Python from PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
+      set(TEST_PYTHON_EXE ${PYTHON_EXECUTABLE})
+    else()
+      message(FATAL_ERROR "Tests: unable to find a Python executable to run the tests.")
     endif()
-    unset(_python_exe)
   endif()
+  unset(_python_exe)
 endif()
 
 # For testing with Valgrind



More information about the Bf-blender-cvs mailing list