[Piglit] [PATCH] Fix test generation on Arch Linux.

Paul Berry stereotype441 at gmail.com
Sat Aug 6 17:29:38 PDT 2011


On Arch Linux, "python" means Python 3.x, and Python 2.x is called
"python2".  The test generation code requires Python 2.x.  In many
other distributions, "python" refers to Python 2.x.

This patch adds logic to the toplevel CMakeLists that checks both
"python2" and "python" to see which one is Python 2.x, and once it is
found, sets the cmake variable ${python} to point to it.
---
 CMakeLists.txt                 |   25 ++++++++++++++++---------
 generated_tests/CMakeLists.txt |    4 ++--
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7cca31e..dab4cfd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,19 +14,26 @@ find_package(PNG REQUIRED)
 find_package(X11)
 
 # Check for presence of Python 2.6 or greater.
-execute_process(
-	COMMAND python -c "import sys; assert sys.version >= '2.6'"
-	OUTPUT_QUIET
-	ERROR_QUIET
-	RESULT_VARIABLE python_version_check_error_code)
-if(NOT python_version_check_error_code EQUAL 0)
-	message(FATAL_ERROR "python version 2.6 or greater required")
-endif(NOT python_version_check_error_code EQUAL 0)
+foreach(python_cmd python2 python)
+	execute_process(
+		COMMAND ${python_cmd} -c "import sys; assert '2.6' <= sys.version < '3'"
+		OUTPUT_QUIET
+		ERROR_QUIET
+		RESULT_VARIABLE python_version_check_error_code)
+	if(python_version_check_error_code EQUAL 0)
+		set(python ${python_cmd})
+		break()
+	endif(python_version_check_error_code EQUAL 0)
+endforeach(python_cmd)
+
+if(NOT DEFINED python)
+	message(FATAL_ERROR "python version 2.x (where x >= 6) required")
+endif(NOT DEFINED python)
 
 # Check for the presence of numpy, which is needed to build generated
 # tests.
 execute_process(
-	COMMAND python -c "import numpy"
+	COMMAND ${python} -c "import numpy"
 	OUTPUT_QUIET
 	ERROR_QUIET
 	RESULT_VARIABLE import_numpy_error_code)
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 79e2a01..e3ff386 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -3,7 +3,7 @@
 set(gen_builtin_uniform
 	${CMAKE_CURRENT_SOURCE_DIR}/gen_builtin_uniform_tests.py)
 execute_process(
-	COMMAND python ${gen_builtin_uniform} --names-only
+	COMMAND ${python} ${gen_builtin_uniform} --names-only
         OUTPUT_VARIABLE builtin_uniform_tests
 	RESULT_VARIABLE builtin_uniform_tests_result)
 if(NOT builtin_uniform_tests_result EQUAL 0)
@@ -14,7 +14,7 @@ string(REPLACE "\n" ";" builtin_uniform_tests ${builtin_uniform_tests})
 # Add a custom command which executes gen_builtin_uniform_tests.py
 # during the build.
 add_custom_command(OUTPUT ${builtin_uniform_tests}
-	COMMAND python ${gen_builtin_uniform}
+	COMMAND ${python} ${gen_builtin_uniform}
 	DEPENDS gen_builtin_uniform_tests.py builtin_function.py
 	VERBATIM)
 
-- 
1.7.6



More information about the Piglit mailing list