@@ -346,7 +346,7 @@ add_custom_command(
346
346
OUTPUT
347
347
${TORCH_GENERATED_CODE}
348
348
COMMAND
349
- " ${Python_EXECUTABLE} " tools/setup_helpers/generate_code.py
349
+ Python::Interpreter tools/setup_helpers/generate_code.py
350
350
--native-functions-path "aten/src/ATen/native/native_functions.yaml"
351
351
--tags-path "aten/src/ATen/native/tags.yaml"
352
352
$<$<BOOL :${INTERN_DISABLE_AUTOGRAD} >:--disable-autograd>
@@ -1094,7 +1094,7 @@ if(BUILD_LITE_INTERPRETER AND SELECTED_OP_LIST)
1094
1094
add_custom_command (
1095
1095
OUTPUT ${CMAKE_BINARY_DIR} /aten/src/ATen/selected_mobile_ops.h
1096
1096
COMMAND
1097
- " ${Python_EXECUTABLE} "
1097
+ Python::Interpreter
1098
1098
-m tools.code_analyzer.gen_oplist
1099
1099
--model_file_list_path "${SELECTED_OP_LIST} "
1100
1100
--output_dir "${CMAKE_BINARY_DIR} /aten/src/ATen"
@@ -1109,7 +1109,7 @@ if(BUILD_LITE_INTERPRETER AND SELECTED_OP_LIST)
1109
1109
add_custom_command (
1110
1110
OUTPUT ${CMAKE_BINARY_DIR} /aten/src/ATen/selected_mobile_ops.h
1111
1111
COMMAND
1112
- " ${Python_EXECUTABLE} "
1112
+ Python::Interpreter
1113
1113
-m tools.lite_interpreter.gen_selected_mobile_ops_header
1114
1114
--yaml_file_path "${SELECTED_OP_LIST} "
1115
1115
--output_file_path "${CMAKE_BINARY_DIR} /aten/src/ATen"
@@ -1887,50 +1887,10 @@ endif()
1887
1887
# only rerun when needed.
1888
1888
1889
1889
if (BUILD_PYTHON)
1890
- # Python site-packages
1891
- # Get canonical directory for python site packages (relative to install
1892
- # location). It varies from system to system.
1893
- # We should pin the path separator to the forward slash on Windows.
1894
- # More details can be seen at
1895
- # https://github.com/pytorch/pytorch/tree/main/tools/build_pytorch_libs.bat#note-backslash-munging-on-windows
1896
- pycmd(PYTHON_SITE_PACKAGES "
1897
- import os
1898
- import sysconfig
1899
- relative_site_packages = sysconfig.get_path('purelib').replace(sysconfig.get_path('data'), '').lstrip(os.path.sep)
1900
- print(relative_site_packages)
1901
- " )
1902
- file (TO_CMAKE_PATH ${PYTHON_SITE_PACKAGES} PYTHON_SITE_PACKAGES)
1903
- set (PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES} PARENT_SCOPE) # for Summary
1904
1890
# ---[ Options.
1905
- set (PYTHON_LIB_REL_PATH "${PYTHON_SITE_PACKAGES } " CACHE STRING "Python installation path (relative to CMake installation prefix)" )
1891
+ set (PYTHON_LIB_REL_PATH "${Python_SITELIB } " CACHE STRING "Python installation path (relative to CMake installation prefix)" )
1906
1892
message (STATUS "Using ${PYTHON_LIB_REL_PATH} as python relative installation path" )
1907
- # Python extension suffix
1908
- # Try to get from python through sysconfig.get_env_var('EXT_SUFFIX') first,
1909
- # fallback to ".pyd" if windows and ".so" for all others.
1910
- pycmd(PY_EXT_SUFFIX "
1911
- def get_ext_suffix():
1912
- import sys
1913
- import sysconfig
1914
- return sysconfig.get_config_var('EXT_SUFFIX')
1915
-
1916
- suffix = get_ext_suffix()
1917
- if suffix is not None:
1918
- print(suffix)
1919
- else:
1920
- print()
1921
- " )
1922
- if ("${PY_EXT_SUFFIX} " STREQUAL "" )
1923
- if (MSVC )
1924
- set (PY_EXT_SUFFIX ".pyd" )
1925
- else ()
1926
- set (PY_EXT_SUFFIX ".so" )
1927
- endif ()
1928
- endif ()
1929
1893
1930
- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
1931
- # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 in EmbeddingBag.cpp
1932
- set_source_files_properties (../aten/src/ATen/native/EmbeddingBag.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes)
1933
- endif ()
1934
1894
1935
1895
set (build_files)
1936
1896
foreach (python_src ${PYTHON_SRCS} )
0 commit comments