Skip to content

Commit abd38b9

Browse files
Realized that companion Python script is actually not needed at all, can be replaced with command line
1 parent 02a69d9 commit abd38b9

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

tools/cmake/CheckPythonPackage.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# CMake functions for checking for Python packages
5-
# Requires PYTHON_EXECUTABLE to be defined. Call FindPythonInterp first!
6-
7-
# NOTE: if moving this file, be sure to also move python_packagecheck.py
8-
9-
# must evaluate this now since CMAKE_CURRENT_LIST_DIR doesn't work in function scope
10-
set(PYTHON_PACKAGECHECK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/python_packagecheck.py)
5+
# Requires PYTHON_EXECUTABLE to be defined. Call FindPython first!
116

127
# set OUTPUT_VAR to whether PACKAGENAME was found
138
function(check_python_package PACKAGENAME OUTPUT_VAR)
@@ -35,7 +30,7 @@ function(check_python_package PACKAGENAME OUTPUT_VAR)
3530
set(PY_INTERP_FOR_${OUTPUT_VAR} ${Python3_EXECUTABLE} CACHE INTERNAL "The python interpreter used to run the ${OUTPUT_VAR} check" FORCE)
3631

3732
execute_process(
38-
COMMAND ${Python3_EXECUTABLE} ${PYTHON_PACKAGECHECK_SCRIPT} ${PACKAGENAME} RESULT_VARIABLE PACKAGECHECK_RESULT
33+
COMMAND ${Python3_EXECUTABLE} -c "import ${PACKAGENAME}" RESULT_VARIABLE PACKAGECHECK_RESULT
3934
)
4035

4136
if(${PACKAGECHECK_RESULT} EQUAL 0)
@@ -67,5 +62,5 @@ function(verify_python_package PACKAGENAME)
6762
if(NOT ${HAVE_VAR_NAME})
6863
message(FATAL_ERROR "The required Python package ${PACKAGENAME} was not found in ${Python3_EXECUTABLE}. Please install it.")
6964
endif()
70-
65+
7166
endfunction(verify_python_package)

tools/cmake/python_packagecheck.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)