You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
4.8 KiB
83 lines
4.8 KiB
6 years ago
|
From ad35b79e3f98b4ce30481e0299cca550ed77aef0 Mon Sep 17 00:00:00 2001
|
||
|
From: Alexander Alekhin <alexander.a.alekhin@gmail.com>
|
||
|
Date: Thu, 22 Nov 2018 21:06:33 +0000
|
||
|
Subject: [PATCH] python: update install paths
|
||
|
|
||
|
- don't require "OPENCV_PYTHON{2,3}_INSTALL_PATH" if OPENCV_SKIP_PYTHON_LOADER=ON
|
||
|
- avoid unnecessary relative paths in generated config-X.Y.py
|
||
|
---
|
||
|
CMakeLists.txt | 4 ++--
|
||
|
modules/python/common.cmake | 14 +++++++++-----
|
||
|
2 files changed, 11 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index fde8b578ba0..6298f4438c2 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -1494,7 +1494,7 @@ if(BUILD_opencv_python2)
|
||
|
status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES}" ELSE NO)
|
||
|
endif()
|
||
|
status(" numpy:" PYTHON2_NUMPY_INCLUDE_DIRS THEN "${PYTHON2_NUMPY_INCLUDE_DIRS} (ver ${PYTHON2_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
|
||
|
- status(" packages path:" PYTHON2_EXECUTABLE THEN "${PYTHON2_PACKAGES_PATH}" ELSE "-")
|
||
|
+ status(" install path:" HAVE_opencv_python2 THEN "${__INSTALL_PATH_PYTHON2}" ELSE "-")
|
||
|
endif()
|
||
|
|
||
|
if(BUILD_opencv_python3)
|
||
|
@@ -1507,7 +1507,7 @@ if(BUILD_opencv_python3)
|
||
|
status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES}" ELSE NO)
|
||
|
endif()
|
||
|
status(" numpy:" PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
|
||
|
- status(" packages path:" PYTHON3_EXECUTABLE THEN "${PYTHON3_PACKAGES_PATH}" ELSE "-")
|
||
|
+ status(" install path:" HAVE_opencv_python3 THEN "${__INSTALL_PATH_PYTHON3}" ELSE "-")
|
||
|
endif()
|
||
|
|
||
|
status("")
|
||
|
diff --git a/modules/python/common.cmake b/modules/python/common.cmake
|
||
|
index 14912297eae..4b4eaa6e7f8 100644
|
||
|
--- a/modules/python/common.cmake
|
||
|
+++ b/modules/python/common.cmake
|
||
|
@@ -122,6 +122,8 @@ endif()
|
||
|
|
||
|
if(NOT " ${PYTHON}" STREQUAL " PYTHON" AND DEFINED OPENCV_${PYTHON}_INSTALL_PATH)
|
||
|
set(__python_binary_install_path "${OPENCV_${PYTHON}_INSTALL_PATH}")
|
||
|
+elseif(OPENCV_SKIP_PYTHON_LOADER AND DEFINED ${PYTHON}_PACKAGES_PATH)
|
||
|
+ set(__python_binary_install_path "${${PYTHON}_PACKAGES_PATH}")
|
||
|
else()
|
||
|
ocv_assert(DEFINED OPENCV_PYTHON_INSTALL_PATH)
|
||
|
set(__python_binary_install_path "${OPENCV_PYTHON_INSTALL_PATH}/${__python_loader_subdir}python-${${PYTHON}_VERSION_MAJOR}.${${PYTHON}_VERSION_MINOR}")
|
||
|
@@ -134,6 +136,8 @@ install(TARGETS ${the_module}
|
||
|
${PYTHON_INSTALL_ARCHIVE}
|
||
|
)
|
||
|
|
||
|
+set(__INSTALL_PATH_${PYTHON} "${__python_binary_install_path}" CACHE INTERNAL "") # CMake status
|
||
|
+
|
||
|
if(NOT OPENCV_SKIP_PYTHON_LOADER)
|
||
|
ocv_assert(DEFINED OPENCV_PYTHON_INSTALL_PATH)
|
||
|
if(OpenCV_FOUND)
|
||
|
@@ -143,12 +147,11 @@ if(NOT OPENCV_SKIP_PYTHON_LOADER)
|
||
|
endif()
|
||
|
|
||
|
set(__python_loader_install_tmp_path "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/install/python_loader/")
|
||
|
+ set(OpenCV_PYTHON_LOADER_FULL_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_PYTHON_INSTALL_PATH}/cv2")
|
||
|
if(IS_ABSOLUTE "${OPENCV_PYTHON_INSTALL_PATH}")
|
||
|
- set(OpenCV_PYTHON_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/")
|
||
|
- set(CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE "'${CMAKE_INSTALL_PREFIX}'")
|
||
|
+ set(CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE "'${OPENCV_PYTHON_INSTALL_PATH}/cv2'")
|
||
|
else()
|
||
|
- file(RELATIVE_PATH OpenCV_PYTHON_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${OPENCV_PYTHON_INSTALL_PATH}/cv2" ${CMAKE_INSTALL_PREFIX})
|
||
|
- set(CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE "os.path.join(LOADER_DIR, '${OpenCV_PYTHON_INSTALL_PATH_RELATIVE_CONFIGCMAKE}')")
|
||
|
+ set(CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE "LOADER_DIR")
|
||
|
endif()
|
||
|
|
||
|
if(DEFINED ${PYTHON}_VERSION_MINOR)
|
||
|
@@ -167,7 +170,8 @@ if(NOT OPENCV_SKIP_PYTHON_LOADER)
|
||
|
if(IS_ABSOLUTE __python_binary_install_path)
|
||
|
set(CMAKE_PYTHON_EXTENSION_PATH "'${__python_binary_install_path}'")
|
||
|
else()
|
||
|
- set(CMAKE_PYTHON_EXTENSION_PATH "os.path.join(${CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE}, '${__python_binary_install_path}')")
|
||
|
+ file(RELATIVE_PATH OpenCV_PYTHON_BINARY_RELATIVE_INSTALL_PATH "${OpenCV_PYTHON_LOADER_FULL_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${__python_binary_install_path}")
|
||
|
+ set(CMAKE_PYTHON_EXTENSION_PATH "os.path.join(${CMAKE_PYTHON_EXTENSION_INSTALL_PATH_BASE}, '${OpenCV_PYTHON_BINARY_RELATIVE_INSTALL_PATH}')")
|
||
|
endif()
|
||
|
configure_file("${PYTHON_SOURCE_DIR}/package/template/config-x.y.py.in" "${__python_loader_install_tmp_path}/cv2/${__target_config}" @ONLY)
|
||
|
install(FILES "${__python_loader_install_tmp_path}/cv2/${__target_config}" DESTINATION "${OPENCV_PYTHON_INSTALL_PATH}/cv2/" COMPONENT python)
|