From 229bc5a93729d72b97a77759b2ba991008c4e330 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 10 Oct 2022 04:46:41 -0700 Subject: [PATCH] Do not depend on unversioned python binary (#1496) Some linux distributions no longer provide `python` binary and require usage of `python3` instead. This changes the scripts here and uses cmake `find_package(Python3` when running python. Co-authored-by: Dominic Hamon --- CMakeLists.txt | 1 + test/AssemblyTests.cmake | 2 +- tools/compare.py | 2 +- tools/strip_asm.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae1f2ef1..22b5306b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,6 +332,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include) add_subdirectory(src) if (BENCHMARK_ENABLE_TESTING) + find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter) enable_testing() if (BENCHMARK_ENABLE_GTEST_TESTS AND NOT (TARGET gtest AND TARGET gtest_main AND diff --git a/test/AssemblyTests.cmake b/test/AssemblyTests.cmake index c43c711f..9ebe948e 100644 --- a/test/AssemblyTests.cmake +++ b/test/AssemblyTests.cmake @@ -47,7 +47,7 @@ macro(add_filecheck_test name) set_target_properties(${name} PROPERTIES COMPILE_FLAGS "-S ${ASM_TEST_FLAGS}") set(ASM_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}.s") add_custom_target(copy_${name} ALL - COMMAND ${PROJECT_SOURCE_DIR}/tools/strip_asm.py + COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/strip_asm.py $ ${ASM_OUTPUT_FILE} BYPRODUCTS ${ASM_OUTPUT_FILE}) diff --git a/tools/compare.py b/tools/compare.py index 01d2c89f..8cefdd17 100755 --- a/tools/compare.py +++ b/tools/compare.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest """ diff --git a/tools/strip_asm.py b/tools/strip_asm.py index 9030550b..d131dc71 100755 --- a/tools/strip_asm.py +++ b/tools/strip_asm.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ strip_asm.py - Cleanup ASM output for the specified file