Skip to content

Commit

Permalink
[libtorch] python site-packages search
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed Nov 2, 2024
1 parent 8fa61e1 commit 8c6cee1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions ports/libtorch/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ x_vcpkg_get_python_packages(
)
message(STATUS "Using Python3: ${PYTHON3}")

get_filename_component(PYTHON_PATH "${PYTHON3}" PATH)
get_filename_component(PYTHON_ROOT "${PYTHON_PATH}" PATH)
find_path(SITE_PACKAGES_DIR
NAMES "typing_extensions.py"
PATHS "${PYTHON_ROOT}/Lib/site-packages"
"${PYTHON_ROOT}/lib/python3.11/site-packages"
"${PYTHON_ROOT}/lib/python3.12/site-packages"
"${PYTHON_ROOT}/lib/python3.13/site-packages"
REQUIRED
)
function(get_python_site_packages PYTHON OUT_PATH)
execute_process(
COMMAND "${PYTHON}" -c "import site; print(site.getsitepackages()[0])"
OUTPUT_VARIABLE output OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(${OUT_PATH} "${output}" PARENT_SCOPE)
endfunction()
get_python_site_packages("${PYTHON3}" SITE_PACKAGES_DIR)

get_filename_component(pybind11_DIR "${SITE_PACKAGES_DIR}/pybind11/share/cmake/pybind11" ABSOLUTE)
message(STATUS "Using pybind11: ${pybind11_DIR}")

Expand Down

0 comments on commit 8c6cee1

Please sign in to comment.