ports/misc/py-pytorch/files/patch-caffe2_CMakeLists.txt
2024-08-27 12:44:06 -07:00

28 lines
1.3 KiB
Text

- fix regression in python install path in 2.4.0
--- caffe2/CMakeLists.txt.orig 2024-07-24 18:41:35 UTC
+++ caffe2/CMakeLists.txt
@@ -1897,8 +1897,22 @@ if(BUILD_PYTHON)
# only rerun when needed.
if(BUILD_PYTHON)
+ # Python site-packages
+ # Get canonical directory for python site packages (relative to install
+ # location). It varies from system to system.
+ # We should pin the path separator to the forward slash on Windows.
+ # More details can be seen at
+ # https://github.com/pytorch/pytorch/tree/main/tools/build_pytorch_libs.bat#note-backslash-munging-on-windows
+ pycmd(PYTHON_SITE_PACKAGES "
+ import os
+ import sysconfig
+ relative_site_packages = sysconfig.get_path('purelib').replace(sysconfig.get_path('data'), '').lstrip(os.path.sep)
+ print(relative_site_packages)
+ ")
+ file(TO_CMAKE_PATH ${PYTHON_SITE_PACKAGES} PYTHON_SITE_PACKAGES)
+ set(PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES} PARENT_SCOPE) # for Summary
# ---[ Options.
- set(PYTHON_LIB_REL_PATH "${Python_SITELIB}" CACHE STRING "Python installation path (relative to CMake installation prefix)")
+ set(PYTHON_LIB_REL_PATH "${PYTHON_SITE_PACKAGES}" CACHE STRING "Python installation path (relative to CMake installation prefix)")
message(STATUS "Using ${PYTHON_LIB_REL_PATH} as python relative installation path")