Skip to content

Commit 1c1a810

Browse files
committed
libclc: Use find_package to find Python 3 and require it
The script's shebang wants Python 3, so we use FindPython3. The original code didn'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. Lastly remove the shebang, since the script is only run via interpreter and doesn't have the executable bit set anyway. Reviewed By: jvesely Differential Revision: https://reviews.llvm.org/D88366
1 parent 7345753 commit 1c1a810

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

libclc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ if( ENABLE_RUNTIME_SUBNORMAL )
184184
DESTINATION ${CMAKE_INSTALL_DATADIR}/clc )
185185
endif()
186186

187-
find_program( PYTHON python )
187+
find_package( Python3 REQUIRED COMPONENTS Interpreter )
188188
file( TO_CMAKE_PATH ${CMAKE_SOURCE_DIR}/generic/lib/gen_convert.py script_loc )
189189
add_custom_command(
190190
OUTPUT convert.cl
191-
COMMAND ${PYTHON} ${script_loc} > convert.cl
191+
COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
192192
DEPENDS ${script_loc} )
193193
add_custom_target( "generate_convert.cl" DEPENDS convert.cl )
194194

libclc/generic/lib/gen_convert.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
31
# OpenCL built-in library: type conversion functions
42
#
53
# Copyright (c) 2013 Victor Oliveira <[email protected]>

0 commit comments

Comments
 (0)