[PATCH] D88366: libclc: Use find_package to find python and require it

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 14:23:55 PDT 2020


aaronpuchert created this revision.
aaronpuchert added a reviewer: jvesely.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.
aaronpuchert requested review of this revision.

The script's shebang wants Python 3 and FindPython prefers that. But it
still allows Python 2, in case the script also works with that. So it
basically works like the previous code, except that the previous code
wouldn't work when an unversioned python was not available. This is
explicitly allowed in PEP 394. ("Distributors may choose to set the
behavior of the python command as follows: python2, python3, not provide
python command, allow python to be configurable by an end user or a
system administrator."

Also I think it's actually required, so let the configuration fail if we
can't find it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88366

Files:
  libclc/CMakeLists.txt


Index: libclc/CMakeLists.txt
===================================================================
--- libclc/CMakeLists.txt
+++ libclc/CMakeLists.txt
@@ -184,11 +184,11 @@
 		DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
 endif()
 
-find_program( PYTHON python )
+find_package( Python REQUIRED COMPONENTS Interpreter )
 file( TO_CMAKE_PATH ${CMAKE_SOURCE_DIR}/generic/lib/gen_convert.py script_loc )
 add_custom_command(
 	OUTPUT convert.cl
-	COMMAND ${PYTHON} ${script_loc} > convert.cl
+	COMMAND ${Python_EXECUTABLE} ${script_loc} > convert.cl
 	DEPENDS ${script_loc} )
 add_custom_target( "generate_convert.cl" DEPENDS convert.cl )
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88366.294518.patch
Type: text/x-patch
Size: 633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200926/df1c7147/attachment.bin>


More information about the llvm-commits mailing list