Skip to content

Commit 0910429

Browse files
malfetpytorchmergebot
authored andcommitted
[BE][CMake] Use FindPython module (pytorch#124613)
As FindPythonInterp and FindPythonLibs has been deprecated since cmake-3.12 Replace `PYTHON_EXECUTABLE` with `Python_EXECUTABLE` everywhere (CMake variable names are case-sensitive) This makes PyTorch buildable with python3 binary shipped with XCode on MacOS TODO: Get rid of `FindNumpy` as its part of Python package Pull Request resolved: pytorch#124613 Approved by: https://github.com/cyyever, https://github.com/Skylion007
1 parent 942d9ab commit 0910429

16 files changed

+53
-93
lines changed

.ci/pytorch/build.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ else
330330
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
331331
mkdir -p "$CUSTOM_OP_BUILD"
332332
pushd "$CUSTOM_OP_BUILD"
333-
cmake "$CUSTOM_OP_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPYTHON_EXECUTABLE="$(which python)" \
333+
cmake "$CUSTOM_OP_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPython_EXECUTABLE="$(which python)" \
334334
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
335335
make VERBOSE=1
336336
popd
@@ -343,7 +343,7 @@ else
343343
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
344344
mkdir -p "$JIT_HOOK_BUILD"
345345
pushd "$JIT_HOOK_BUILD"
346-
cmake "$JIT_HOOK_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPYTHON_EXECUTABLE="$(which python)" \
346+
cmake "$JIT_HOOK_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPython_EXECUTABLE="$(which python)" \
347347
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
348348
make VERBOSE=1
349349
popd
@@ -355,7 +355,7 @@ else
355355
python --version
356356
mkdir -p "$CUSTOM_BACKEND_BUILD"
357357
pushd "$CUSTOM_BACKEND_BUILD"
358-
cmake "$CUSTOM_BACKEND_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPYTHON_EXECUTABLE="$(which python)" \
358+
cmake "$CUSTOM_BACKEND_TEST" -DCMAKE_PREFIX_PATH="$SITE_PACKAGES/torch" -DPython_EXECUTABLE="$(which python)" \
359359
-DCMAKE_MODULE_PATH="$CUSTOM_TEST_MODULE_PATH" -DUSE_ROCM="$CUSTOM_TEST_USE_ROCM"
360360
make VERBOSE=1
361361
popd

caffe2/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ add_custom_command(
388388
OUTPUT
389389
${TORCH_GENERATED_CODE}
390390
COMMAND
391-
"${PYTHON_EXECUTABLE}" tools/setup_helpers/generate_code.py
391+
"${Python_EXECUTABLE}" tools/setup_helpers/generate_code.py
392392
--native-functions-path "aten/src/ATen/native/native_functions.yaml"
393393
--tags-path "aten/src/ATen/native/tags.yaml"
394394
$<$<BOOL:${INTERN_DISABLE_AUTOGRAD}>:--disable-autograd>
@@ -1144,7 +1144,7 @@ if(BUILD_LITE_INTERPRETER AND SELECTED_OP_LIST)
11441144
add_custom_command(
11451145
OUTPUT ${CMAKE_BINARY_DIR}/aten/src/ATen/selected_mobile_ops.h
11461146
COMMAND
1147-
"${PYTHON_EXECUTABLE}"
1147+
"${Python_EXECUTABLE}"
11481148
-m tools.code_analyzer.gen_oplist
11491149
--model_file_list_path "${SELECTED_OP_LIST}"
11501150
--output_dir "${CMAKE_BINARY_DIR}/aten/src/ATen"
@@ -1159,7 +1159,7 @@ if(BUILD_LITE_INTERPRETER AND SELECTED_OP_LIST)
11591159
add_custom_command(
11601160
OUTPUT ${CMAKE_BINARY_DIR}/aten/src/ATen/selected_mobile_ops.h
11611161
COMMAND
1162-
"${PYTHON_EXECUTABLE}"
1162+
"${Python_EXECUTABLE}"
11631163
-m tools.lite_interpreter.gen_selected_mobile_ops_header
11641164
--yaml_file_path "${SELECTED_OP_LIST}"
11651165
--output_file_path "${CMAKE_BINARY_DIR}/aten/src/ATen"

cmake/Codegen.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ if(INTERN_BUILD_ATEN_OPS)
114114
file(GLOB_RECURSE all_unboxing_script "${CMAKE_CURRENT_LIST_DIR}/../tools/jit/*.py")
115115
list(APPEND CUSTOM_BUILD_FLAGS --skip_dispatcher_op_registration)
116116
set(GEN_UNBOXING_COMMAND
117-
"${PYTHON_EXECUTABLE}" -m tools.jit.gen_unboxing
117+
"${Python_EXECUTABLE}" -m tools.jit.gen_unboxing
118118
--source-path ${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen
119119
--install_dir ${CMAKE_BINARY_DIR}/aten/src/ATen
120120
)
@@ -158,7 +158,7 @@ if(INTERN_BUILD_ATEN_OPS)
158158
endif()
159159

160160
set(GEN_COMMAND
161-
"${PYTHON_EXECUTABLE}" -m torchgen.gen
161+
"${Python_EXECUTABLE}" -m torchgen.gen
162162
--source-path ${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen
163163
--install_dir ${CMAKE_BINARY_DIR}/aten/src/ATen
164164
${GEN_PER_OPERATOR_FLAG}
@@ -356,7 +356,7 @@ function(append_filelist name outputvar)
356356
${PROJECT_SOURCE_DIR}/build_variables.bzl
357357
${PROJECT_BINARY_DIR}/caffe2/build_variables.bzl)
358358
execute_process(
359-
COMMAND "${PYTHON_EXECUTABLE}" -c
359+
COMMAND "${Python_EXECUTABLE}" -c
360360
"exec(open('${PROJECT_SOURCE_DIR}/build_variables.bzl').read());print(';'.join(['${_rootdir}' + x for x in ${name}]))"
361361
WORKING_DIRECTORY "${_rootdir}"
362362
RESULT_VARIABLE _retval

cmake/Dependencies.cmake

+15-51
Original file line numberDiff line numberDiff line change
@@ -837,76 +837,43 @@ include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
837837
# ---[ Python + Numpy
838838
if(BUILD_PYTHON)
839839
# If not given a Python installation, then use the current active Python
840-
if(NOT PYTHON_EXECUTABLE)
840+
if(NOT Python_EXECUTABLE)
841841
execute_process(
842-
COMMAND "which" "python" RESULT_VARIABLE _exitcode OUTPUT_VARIABLE _py_exe)
842+
COMMAND "which" "python3" RESULT_VARIABLE _exitcode OUTPUT_VARIABLE _py_exe)
843843
if(${_exitcode} EQUAL 0)
844844
if(NOT MSVC)
845-
string(STRIP ${_py_exe} PYTHON_EXECUTABLE)
845+
string(STRIP ${_py_exe} Python_EXECUTABLE)
846846
endif()
847-
message(STATUS "Setting Python to ${PYTHON_EXECUTABLE}")
847+
message(STATUS "Setting Python to ${Python_EXECUTABLE}")
848848
endif()
849849
endif()
850850

851851
# Check that Python works
852852
set(PYTHON_VERSION)
853-
if(DEFINED PYTHON_EXECUTABLE)
853+
if(DEFINED Python_EXECUTABLE)
854854
execute_process(
855-
COMMAND "${PYTHON_EXECUTABLE}" "--version"
855+
COMMAND "${Python_EXECUTABLE}" "--version"
856856
RESULT_VARIABLE _exitcode OUTPUT_VARIABLE PYTHON_VERSION)
857857
if(NOT _exitcode EQUAL 0)
858-
message(FATAL_ERROR "The Python executable ${PYTHON_EXECUTABLE} cannot be run. Make sure that it is an absolute path.")
858+
message(FATAL_ERROR "The Python executable ${Python_EXECUTABLE} cannot be run. Make sure that it is an absolute path.")
859859
endif()
860860
if(PYTHON_VERSION)
861861
string(REGEX MATCH "([0-9]+)\\.([0-9]+)" PYTHON_VERSION ${PYTHON_VERSION})
862862
endif()
863863
endif()
864864

865-
# Seed PYTHON_INCLUDE_DIR and PYTHON_LIBRARY to be consistent with the
866-
# executable that we already found (if we didn't actually find an executable
867-
# then these will just use "python", but at least they'll be consistent with
868-
# each other).
869-
if(NOT PYTHON_INCLUDE_DIR)
870-
# TODO: Verify that sysconfig isn't inaccurate
871-
pycmd_no_exit(_py_inc _exitcode "import sysconfig; print(sysconfig.get_path('include'))")
872-
if("${_exitcode}" EQUAL 0 AND IS_DIRECTORY "${_py_inc}")
873-
set(PYTHON_INCLUDE_DIR "${_py_inc}")
874-
message(STATUS "Setting Python's include dir to ${_py_inc} from sysconfig")
875-
else()
876-
message(WARNING "Could not set Python's include dir to ${_py_inc} from sysconfig")
877-
endif()
878-
endif(NOT PYTHON_INCLUDE_DIR)
879-
880-
if(NOT PYTHON_LIBRARY)
881-
pycmd_no_exit(_py_lib _exitcode "import sysconfig; print(sysconfig.get_path('stdlib'))")
882-
if("${_exitcode}" EQUAL 0 AND EXISTS "${_py_lib}" AND EXISTS "${_py_lib}")
883-
set(PYTHON_LIBRARY "${_py_lib}")
884-
if(MSVC)
885-
string(REPLACE "Lib" "libs" _py_static_lib ${_py_lib})
886-
link_directories(${_py_static_lib})
887-
endif()
888-
message(STATUS "Setting Python's library to ${PYTHON_LIBRARY}")
889-
endif()
890-
endif(NOT PYTHON_LIBRARY)
891-
892865
# These should fill in the rest of the variables, like versions, but resepct
893866
# the variables we set above
894-
set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION} 3.8)
895-
find_package(PythonInterp 3.0)
896-
find_package(PythonLibs 3.0)
867+
find_package(Python COMPONENTS Interpreter Development)
897868

898-
if(NOT PYTHONLIBS_VERSION_STRING)
869+
if(NOT Python_Development_FOUND)
899870
message(FATAL_ERROR
900871
"Python development libraries could not be found.")
901872
endif()
902873

903-
if(${PYTHONLIBS_VERSION_STRING} VERSION_LESS 3)
904-
message(FATAL_ERROR
905-
"Found Python libraries version ${PYTHONLIBS_VERSION_STRING}. Python 2 has reached end-of-life and is no longer supported by PyTorch.")
906-
endif()
907-
if(${PYTHONLIBS_VERSION_STRING} VERSION_LESS 3.8)
874+
if(${Python_VERSION} VERSION_LESS 3.8)
908875
message(FATAL_ERROR
909-
"Found Python libraries version ${PYTHONLIBS_VERSION_STRING}. Python < 3.8 is no longer supported by PyTorch.")
876+
"Found Python libraries version ${Python_VERSION}. Python < 3.8 is no longer supported by PyTorch.")
910877
endif()
911878

912879
# When building pytorch, we pass this in directly from setup.py, and
@@ -920,11 +887,11 @@ if(BUILD_PYTHON)
920887
endif()
921888
endif()
922889

923-
if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
890+
if(Python_Interpreter_FOUND AND Python_Development_FOUND)
924891
add_library(python::python INTERFACE IMPORTED)
925-
target_include_directories(python::python SYSTEM INTERFACE ${PYTHON_INCLUDE_DIRS})
892+
target_include_directories(python::python SYSTEM INTERFACE ${Python_INCLUDE_DIRS})
926893
if(WIN32)
927-
target_link_libraries(python::python INTERFACE ${PYTHON_LIBRARIES})
894+
target_link_libraries(python::python INTERFACE ${Python_LIBRARIES})
928895
endif()
929896

930897
caffe2_update_option(USE_NUMPY OFF)
@@ -960,10 +927,7 @@ endif()
960927
message(STATUS "pybind11 include dirs: " "${pybind11_INCLUDE_DIRS}")
961928
add_library(pybind::pybind11 INTERFACE IMPORTED)
962929
target_include_directories(pybind::pybind11 SYSTEM INTERFACE ${pybind11_INCLUDE_DIRS})
963-
target_link_libraries(pybind::pybind11 INTERFACE python::python)
964-
if(APPLE)
965-
target_link_options(pybind::pybind11 INTERFACE -undefined dynamic_lookup)
966-
endif()
930+
target_link_libraries(pybind::pybind11 INTERFACE Python::Module)
967931

968932
# ---[ OpenTelemetry API headers
969933
find_package(OpenTelemetryApi)

cmake/Modules/FindNumPy.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
unset(NUMPY_VERSION)
1616
unset(NUMPY_INCLUDE_DIR)
1717

18-
if(PYTHONINTERP_FOUND)
19-
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
18+
if(Python_Interpreter_FOUND)
19+
execute_process(COMMAND "${Python_EXECUTABLE}" "-c"
2020
"import numpy as n; print(n.__version__); print(n.get_include());"
2121
RESULT_VARIABLE __result
2222
OUTPUT_VARIABLE __output

cmake/Summary.cmake

+5-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ function(caffe2_print_configuration_summary)
3636
message(STATUS " BUILD_DOCS : ${BUILD_DOCS}")
3737
message(STATUS " BUILD_PYTHON : ${BUILD_PYTHON}")
3838
if(${BUILD_PYTHON})
39-
message(STATUS " Python version : ${PYTHON_VERSION_STRING}")
40-
message(STATUS " Python executable : ${PYTHON_EXECUTABLE}")
41-
message(STATUS " Pythonlibs version : ${PYTHONLIBS_VERSION_STRING}")
42-
message(STATUS " Python library : ${PYTHON_LIBRARIES}")
43-
message(STATUS " Python includes : ${PYTHON_INCLUDE_DIRS}")
44-
message(STATUS " Python site-packages: ${PYTHON_SITE_PACKAGES}")
39+
message(STATUS " Python version : ${Python_VERSION}")
40+
message(STATUS " Python executable : ${Python_EXECUTABLE}")
41+
message(STATUS " Python library : ${Python_LIBRARIES}")
42+
message(STATUS " Python includes : ${Python_INCLUDE_DIRS}")
43+
message(STATUS " Python site-package : ${Python_SITELIB}")
4544
endif()
4645
message(STATUS " BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}")
4746
message(STATUS " CAFFE2_USE_MSVC_STATIC_RUNTIME : ${CAFFE2_USE_MSVC_STATIC_RUNTIME}")

cmake/VulkanCodegen.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ list(APPEND NEW_PYTHONPATH "${CMAKE_CURRENT_LIST_DIR}/..")
4242
set(ENV{PYTHONPATH} ${NEW_PYTHONPATH})
4343
execute_process(
4444
COMMAND
45-
"${PYTHON_EXECUTABLE}"
45+
"${Python_EXECUTABLE}"
4646
${CMAKE_CURRENT_LIST_DIR}/../tools/gen_vulkan_spv.py
4747
--glsl-path ${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/vulkan/glsl
4848
--output-path ${VULKAN_GEN_OUTPUT_PATH}

cmake/public/cuda.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ endif()
139139
set(CUDA_CUDA_LIB "${CUDA_cuda_driver_LIBRARY}" CACHE FILEPATH "")
140140
set(CUDA_NVRTC_LIB "${CUDA_nvrtc_LIBRARY}" CACHE FILEPATH "")
141141
if(CUDA_NVRTC_LIB AND NOT CUDA_NVRTC_SHORTHASH)
142-
if("${PYTHON_EXECUTABLE}" STREQUAL "")
143-
set(_python_exe "python")
142+
if("${Python_EXECUTABLE}" STREQUAL "")
143+
set(_python_exe "python3")
144144
else()
145-
set(_python_exe "${PYTHON_EXECUTABLE}")
145+
set(_python_exe "${Python_EXECUTABLE}")
146146
endif()
147147
execute_process(
148148
COMMAND "${_python_exe}" -c

cmake/public/utils.cmake

+9-9
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ endfunction()
101101
# setting to `python -c`, or using with pycmd. This allows multiline code to be
102102
# nested nicely in the surrounding code structure.
103103
#
104-
# This function respsects PYTHON_EXECUTABLE if it defined, otherwise it uses
104+
# This function respsects Python_EXECUTABLE if it defined, otherwise it uses
105105
# `python` and hopes for the best. An error will be thrown if it is not found.
106106
#
107107
# Args:
108108
# outvar : variable that will hold the stdout of the python command
109109
# text : text to remove indentation from
110110
#
111111
function(dedent outvar text)
112-
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
113-
if("${PYTHON_EXECUTABLE}" STREQUAL "")
114-
set(_python_exe "python")
112+
# Use Python_EXECUTABLE if it is defined, otherwise default to python
113+
if("${Python_EXECUTABLE}" STREQUAL "")
114+
set(_python_exe "python3")
115115
else()
116-
set(_python_exe "${PYTHON_EXECUTABLE}")
116+
set(_python_exe "${Python_EXECUTABLE}")
117117
endif()
118118
set(_fixup_cmd "import sys; from textwrap import dedent; print(dedent(sys.stdin.read()))")
119119
file(WRITE "${CMAKE_BINARY_DIR}/indented.txt" "${text}")
@@ -134,11 +134,11 @@ endfunction()
134134

135135

136136
function(pycmd_no_exit outvar exitcode cmd)
137-
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
138-
if("${PYTHON_EXECUTABLE}" STREQUAL "")
137+
# Use Python_EXECUTABLE if it is defined, otherwise default to python
138+
if("${Python_EXECUTABLE}" STREQUAL "")
139139
set(_python_exe "python")
140140
else()
141-
set(_python_exe "${PYTHON_EXECUTABLE}")
141+
set(_python_exe "${Python_EXECUTABLE}")
142142
endif()
143143
# run the actual command
144144
execute_process(
@@ -159,7 +159,7 @@ endfunction()
159159
# Common indentation in the text of `cmd` is removed before the command is
160160
# executed, so the caller does not need to worry about indentation issues.
161161
#
162-
# This function respsects PYTHON_EXECUTABLE if it defined, otherwise it uses
162+
# This function respsects Python_EXECUTABLE if it defined, otherwise it uses
163163
# `python` and hopes for the best. An error will be thrown if it is not found.
164164
#
165165
# Args:

scripts/build_android.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CMAKE_ARGS=()
6161

6262
# Build PyTorch mobile
6363
CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=$($PYTHON -c 'import sysconfig; print(sysconfig.get_path("purelib"))')")
64-
CMAKE_ARGS+=("-DPYTHON_EXECUTABLE=$($PYTHON -c 'import sys; print(sys.executable)')")
64+
CMAKE_ARGS+=("-DPython_EXECUTABLE=$($PYTHON -c 'import sys; print(sys.executable)')")
6565
CMAKE_ARGS+=("-DBUILD_CUSTOM_PROTOBUF=OFF")
6666

6767
# custom build with selected ops

scripts/build_ios.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CMAKE_ARGS=()
2626

2727
# Build PyTorch mobile
2828
CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=$($PYTHON -c 'import sysconfig; print(sysconfig.get_path("purelib"))')")
29-
CMAKE_ARGS+=("-DPYTHON_EXECUTABLE=$($PYTHON -c 'import sys; print(sys.executable)')")
29+
CMAKE_ARGS+=("-DPython_EXECUTABLE=$($PYTHON -c 'import sys; print(sys.executable)')")
3030
CMAKE_ARGS+=("-DBUILD_CUSTOM_PROTOBUF=OFF")
3131

3232
# custom build with selected ops

scripts/build_mobile.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ echo "Caffe2 path: $CAFFE2_ROOT"
1616

1717
CMAKE_ARGS=()
1818
CMAKE_ARGS+=("-DCMAKE_PREFIX_PATH=$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')")
19-
CMAKE_ARGS+=("-DPYTHON_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')")
19+
CMAKE_ARGS+=("-DPython_EXECUTABLE=$(python -c 'import sys; print(sys.executable)')")
2020
CMAKE_ARGS+=("-DBUILD_CUSTOM_PROTOBUF=OFF")
2121
CMAKE_ARGS+=("-DBUILD_SHARED_LIBS=OFF")
2222

scripts/get_python_cmake_flags.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import sysconfig
1818

1919
flags = [
20-
f"-DPYTHON_EXECUTABLE:FILEPATH={sys.executable}",
21-
f"-DPYTHON_INCLUDE_DIR={sysconfig.get_path('include')}",
20+
f"-DPython_EXECUTABLE:FILEPATH={sys.executable}",
2221
]
2322

2423
print(" ".join(flags), end="")

test/edge/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ append_cxx_flag_if_supported("-Wno-unused-private-field" CMAKE_CXX_FLAGS)
99

1010
# Generate unboxing kernels
1111
set(GEN_COMMAND
12-
"${PYTHON_EXECUTABLE}" -m torchgen.gen_executorch
12+
"${Python_EXECUTABLE}" -m torchgen.gen_executorch
1313
--source-path=${TEST_ROOT}
1414
--install-dir=${OUTPUT_DIRECTORY}
1515
--tags-path=${TORCH_ROOT}/aten/src/ATen/native/tags.yaml

tools/setup_helpers/cmake.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ def generate(
307307

308308
CMake.defines(
309309
args,
310-
PYTHON_EXECUTABLE=sys.executable,
311-
PYTHON_LIBRARY=cmake_python_library,
312-
PYTHON_INCLUDE_DIR=sysconfig.get_path("include"),
310+
Python_EXECUTABLE=sys.executable,
313311
TORCH_BUILD_VERSION=version,
314312
NUMPY_INCLUDE_DIR=NUMPY_INCLUDE_DIR,
315313
**build_options,

torch/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ add_custom_command(
216216
"${TORCH_SRC_DIR}/_C/_VariableFunctions.pyi"
217217
"${TORCH_SRC_DIR}/nn/functional.pyi"
218218
COMMAND
219-
"${PYTHON_EXECUTABLE}" -mtools.pyi.gen_pyi
219+
"${Python_EXECUTABLE}" -mtools.pyi.gen_pyi
220220
--native-functions-path "aten/src/ATen/native/native_functions.yaml"
221221
--tags-path "aten/src/ATen/native/tags.yaml"
222222
--deprecated-functions-path "tools/autograd/deprecated.yaml"
@@ -238,7 +238,7 @@ add_custom_command(
238238
OUTPUT
239239
"${TORCH_SRC_DIR}/utils/data/datapipes/datapipe.pyi"
240240
COMMAND
241-
"${PYTHON_EXECUTABLE}" ${TORCH_SRC_DIR}/utils/data/datapipes/gen_pyi.py
241+
"${Python_EXECUTABLE}" ${TORCH_SRC_DIR}/utils/data/datapipes/gen_pyi.py
242242
DEPENDS
243243
"${TORCH_SRC_DIR}/utils/data/datapipes/datapipe.pyi.in"
244244
${datapipe_files}
@@ -383,7 +383,7 @@ add_custom_command(
383383
OUTPUT ${TORCH_SRC_DIR}/version.py
384384
COMMAND "${CMAKE_COMMAND}" -E touch "${TOOLS_PATH}/generate_torch_version.py"
385385
COMMAND
386-
"${PYTHON_EXECUTABLE}" "${TOOLS_PATH}/generate_torch_version.py"
386+
"${Python_EXECUTABLE}" "${TOOLS_PATH}/generate_torch_version.py"
387387
--is-debug=${TORCH_VERSION_DEBUG}
388388
--cuda-version=${CUDA_VERSION}
389389
--hip-version=${HIP_VERSION}

0 commit comments

Comments
 (0)