File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,8 +127,21 @@ if (IMATH_INSTALL)
127127 # Set the PYTHON_INSTALL_DIR but only if it's not already set,
128128 # which allows an externally-set value to take effect.
129129 #
130-
131- set (PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR} .${Python3_VERSION_MINOR} /site-packages" )
130+ # PYTHON_INSTALL_DIR should be a relative path underneath the
131+ # INSTALL_DIR. Set it to Python3_SITEARCH, relative to the python
132+ # system installation.
133+ #
134+
135+ if (NOT Python3_PREFIX)
136+ # if Python3_PREFIX is not set, use the location of the python executable
137+ get_filename_component (Python3_PREFIX "${Python3_EXECUTABLE} " DIRECTORY )
138+ get_filename_component (Python3_PREFIX "${Python3_PREFIX} " DIRECTORY )
139+ endif ()
140+
141+ file (RELATIVE_PATH PYTHON_INSTALL_DIR
142+ "${Python3_PREFIX} "
143+ "${Python3_SITEARCH} " )
144+
132145 message (STATUS "installing ${PYBINDIMATH_MODULE_NAME} to ${PYTHON_INSTALL_DIR} " )
133146
134147 else ()
Original file line number Diff line number Diff line change @@ -212,8 +212,21 @@ if (IMATH_INSTALL)
212212 # Set the PYTHON_INSTALL_DIR but only if it's not already set,
213213 # which allows an externally-set value to take effect.
214214 #
215-
216- set (PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR} .${Python3_VERSION_MINOR} /site-packages" )
215+ # PYTHON_INSTALL_DIR should be a relative path underneath the
216+ # INSTALL_DIR. Set it to Python3_SITEARCH, relative to the python
217+ # system installation.
218+ #
219+
220+ if (NOT Python3_PREFIX)
221+ # if Python3_PREFIX is not set, use the location of the python executable
222+ get_filename_component (Python3_PREFIX "${Python3_EXECUTABLE} " DIRECTORY )
223+ get_filename_component (Python3_PREFIX "${Python3_PREFIX} " DIRECTORY )
224+ endif ()
225+
226+ file (RELATIVE_PATH PYTHON_INSTALL_DIR
227+ "${Python3_PREFIX} "
228+ "${Python3_SITEARCH} " )
229+
217230 message (STATUS "installing ${PYIMATH_MODULE_NAME} module to ${PYTHON_INSTALL_DIR} " )
218231
219232 else ()
Original file line number Diff line number Diff line change @@ -50,14 +50,27 @@ target_link_libraries(${PYIMATHNUMPY_MODULE}
5050
5151if (IMATH_INSTALL)
5252
53- #
54- # Set the PYTHON_INSTALL_DIR but only if it's not already set,
55- # which allows an externally-set value to take effect.
56- #
57-
5853 if (NOT DEFINED PYTHON_INSTALL_DIR)
5954
60- set (PYTHON_INSTALL_DIR "lib/python${Python3_VERSION_MAJOR} .${Python3_VERSION_MINOR} /site-packages" )
55+ #
56+ # Set the PYTHON_INSTALL_DIR but only if it's not already set,
57+ # which allows an externally-set value to take effect.
58+ #
59+ # PYTHON_INSTALL_DIR should be a relative path underneath the
60+ # INSTALL_DIR. Set it to Python3_SITEARCH, relative to the python
61+ # system installation.
62+ #
63+
64+ if (NOT Python3_PREFIX)
65+ # if Python3_PREFIX is not set, use the location of the python executable
66+ get_filename_component (Python3_PREFIX "${Python3_EXECUTABLE} " DIRECTORY )
67+ get_filename_component (Python3_PREFIX "${Python3_PREFIX} " DIRECTORY )
68+ endif ()
69+
70+ file (RELATIVE_PATH PYTHON_INSTALL_DIR
71+ "${Python3_PREFIX} "
72+ "${Python3_SITEARCH} " )
73+
6174 message (STATUS "installing ${PYIMATHNUMPY_MODULE} module to ${PYTHON_INSTALL_DIR} " )
6275
6376 else ()
You can’t perform that action at this time.
0 commit comments