Realized that companion Python script is actually not needed at all, can be replaced with command line

pull/14205/head
Jamie Smith 2021-01-28 01:59:55 -08:00
parent 8eca0cffb2
commit df60d42aed
2 changed files with 3 additions and 21 deletions

View File

@ -2,12 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
# CMake functions for checking for Python packages
# Requires PYTHON_EXECUTABLE to be defined. Call FindPythonInterp first!
# NOTE: if moving this file, be sure to also move python_packagecheck.py
# must evaluate this now since CMAKE_CURRENT_LIST_DIR doesn't work in function scope
set(PYTHON_PACKAGECHECK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/python_packagecheck.py)
# Requires PYTHON_EXECUTABLE to be defined. Call FindPython first!
# set OUTPUT_VAR to whether PACKAGENAME was found
function(check_python_package PACKAGENAME OUTPUT_VAR)
@ -35,7 +30,7 @@ function(check_python_package PACKAGENAME OUTPUT_VAR)
set(PY_INTERP_FOR_${OUTPUT_VAR} ${Python3_EXECUTABLE} CACHE INTERNAL "The python interpreter used to run the ${OUTPUT_VAR} check" FORCE)
execute_process(
COMMAND ${Python3_EXECUTABLE} ${PYTHON_PACKAGECHECK_SCRIPT} ${PACKAGENAME} RESULT_VARIABLE PACKAGECHECK_RESULT
COMMAND ${Python3_EXECUTABLE} -c "import ${PACKAGENAME}" RESULT_VARIABLE PACKAGECHECK_RESULT
)
if(${PACKAGECHECK_RESULT} EQUAL 0)
@ -67,5 +62,5 @@ function(verify_python_package PACKAGENAME)
if(NOT ${HAVE_VAR_NAME})
message(FATAL_ERROR "The required Python package ${PACKAGENAME} was not found in ${Python3_EXECUTABLE}. Please install it.")
endif()
endfunction(verify_python_package)

View File

@ -1,13 +0,0 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Script to check if a Python module/package is installed."""
import sys
try:
__import__(sys.argv[1])
except ImportError:
exit(1)
exit(0)