Skip to content

Commit

Permalink
Fix python module install destination
Browse files Browse the repository at this point in the history
We were installing python modules in the wrong locations (and double
installing pyimath).

* Get rid of the double install.
* Make the one install go to the right destination:
  `<install>/lib/pythonX.Y/site-packages`
* With that in place, we can restore the EXPORT that makes
  the python module show up as a target in the exported cmake config.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz committed May 10, 2024
1 parent 2fc9d89 commit 1939102
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/python/PyImathNumpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ if(TARGET Python2::Python AND
LIBRARY_OUTPUT_NAME "imathnumpy"
DEBUG_POSTFIX ""
)
install(TARGETS imathnumpy_python2 DESTINATION ${PyImath_Python2_SITEARCH_REL})
install(TARGETS imathnumpy_python2
DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
)
endif()

if(TARGET Python3::Python AND
Expand All @@ -48,5 +50,7 @@ if(TARGET Python3::Python AND
LIBRARY_OUTPUT_NAME "imathnumpy"
DEBUG_POSTFIX ""
)
install(TARGETS imathnumpy_python3 DESTINATION ${PyImath_Python3_SITEARCH_REL})
install(TARGETS imathnumpy_python3
DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
)
endif()
16 changes: 8 additions & 8 deletions src/python/config/ModuleDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ function(PYIMATH_ADD_LIBRARY_PRIV libname)
)

add_library(${PROJECT_NAME}::${libname} ALIAS ${libname})

install(TARGETS ${libname}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endfunction()

# NB: This function has a number if specific names / variables
Expand Down Expand Up @@ -130,7 +124,10 @@ function(PYIMATH_DEFINE_MODULE modname)
LIBRARY_OUTPUT_NAME "${modname}"
DEBUG_POSTFIX ""
)
install(TARGETS ${modname}_python2 DESTINATION ${PyImath_Python2_SITEARCH_REL})
install(TARGETS ${modname}_python2
EXPORT ${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}/site-packages"
)
endif()
else()
if(TARGET Python3::Python)
Expand All @@ -157,7 +154,10 @@ function(PYIMATH_DEFINE_MODULE modname)
LIBRARY_OUTPUT_NAME "${modname}"
DEBUG_POSTFIX ""
)
install(TARGETS ${modname}_python3 DESTINATION ${PyImath_Python3_SITEARCH_REL})
install(TARGETS ${modname}_python3
EXPORT ${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_BINDIR}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages"
)
endif()
endif()
endfunction()

0 comments on commit 1939102

Please sign in to comment.