Undebianize PYTHON_PACKAGES_PATH and be distribution-agnostic (Bug #1204)
Description
Prior to OpenCV 2.3, all Python libraries were placed in '$pythonlibdir/site-packages', a standard location and widely followed convention across many UNIX and Linux distributions.
In the latest 2.3 release, we see that this has changed due to an earlier bug report r1. A code extract of the change is as follows:
2.2.0¶
if(UNIX)
set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv)
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages)
endif()
if(WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv")
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
2.3.0¶
if(UNIX)
set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv)
if(APPLE)
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.")
else() #debian based assumed, install to the dist-packages.
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
endif()
if(WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv")
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
Python's convention may have changed and shifted the directory to "dist-packages", and Debian may have adopted this latest convention, but this fact alone does not make it necessary for other software developers to enforce the same convention.
This causes extra ammendments to buildscripts and hardcoding data. One either needs to patch [attached] the CMake configuration file (if one wants the build process to be version-agnostic) or pass a version-dependent variable to CMake in the form of "-D PYTHON_PACKAGES_PATH=/lib/python$pyver/site-packages".
I believe it is not upstream's duty to enforce a convention, but instead allow room for downstream to fit into the upstream build system with whatever adoption of conventions it has made. In this case, such a provision is already there, in the form of the above-mentioned 'PYTHON_PACKAGES_PATH', which Debian packagers can use.
History
Updated by Ray Rashif over 13 years ago
Sorry, r1 was supposed to refer to this:
Updated by Ray Rashif over 13 years ago
It doesn't look like it is any official Python convention at all. In fact, it looks like yet another Debian policy. All the more reason to stay away from it and let the distribution handle it.
http://mail.python.org/pipermail/python-dev/2009-July/090730.html (no consensus)
http://docs.python.org/install/index.html#how-installation-works (no mention of "dist-packages")
Updated by Vadim Pisarevsky over 13 years ago
fixed in r5919 (trunk)
- Status changed from Open to Done
- (deleted custom field) set to fixed