Skip to content

Commit

Permalink
Add function to install python package editable during configure (#12)
Browse files Browse the repository at this point in the history
* Add function to install python package editable during configure
* Bump version to 0.5.0

---------

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored Oct 11, 2024
1 parent b229644 commit 19a1d96
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
4 changes: 2 additions & 2 deletions everest-cmake-config-version.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
set(PACKAGE_VERSION 0.4.3)
set(PACKAGE_VERSION 0.5.0)

if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
elseif (PACKAGE_FIND_VERSION_MAJOR STREQUAL "0")
if (PACKAGE_FIND_VERSION_MINOR GREATER "4")
if (PACKAGE_FIND_VERSION_MINOR GREATER "5")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
else ()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
Expand Down
52 changes: 52 additions & 0 deletions python-package-helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,55 @@ macro(ev_setup_cmake_variables_python_wheel)
endif()
message(STATUS "${PROJECT_NAME}_WHEEL_INSTALL_PREFIX=${${PROJECT_NAME}_WHEEL_INSTALL_PREFIX}")
endmacro()


function(ev_pip_install_local)
set(oneValueArgs
PACKAGE_NAME
PACKAGE_SOURCE_DIRECTORY
)
set(multiValueArgs
DEPENDS
)
cmake_parse_arguments(
"EV_PIP_INSTALL_LOCAL"
""
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
if ("${EV_PIP_INSTALL_LOCAL_PACKAGE_NAME}" STREQUAL "")
message(FATAL_ERROR "PACKAGE_NAME is required")
endif()
if ("${EV_PIP_INSTALL_LOCAL_PACKAGE_SOURCE_DIRECTORY}" STREQUAL "")
set(EV_PIP_INSTALL_LOCAL_PACKAGE_SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()

execute_process(
COMMAND
${Python3_EXECUTABLE} -c "from setuptools import setup; setup()" --version
WORKING_DIRECTORY
${EV_PIP_INSTALL_LOCAL_PACKAGE_SOURCE_DIRECTORY}
OUTPUT_VARIABLE
EV_PIP_INSTALL_LOCAL_INSTALLED_PACKAGE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(CHECK_DONE_FILE "${CMAKE_BINARY_DIR}/${EV_PIP_INSTALL_LOCAL_PACKAGE_NAME}_pip_install_local_installed_${EV_PIP_INSTALL_LOCAL_INSTALLED_PACKAGE_VERSION}")
if(NOT EXISTS "${CHECK_DONE_FILE}")
message(STATUS "${EV_PIP_INSTALL_LOCAL_PACKAGE_NAME} not found, installing.")
execute_process(
COMMAND
${Python3_EXECUTABLE} -m pip install --force-reinstall -e .
WORKING_DIRECTORY
${EV_PIP_INSTALL_LOCAL_PACKAGE_SOURCE_DIRECTORY}
RESULTS_VARIABLE EV_RESULTS
)
execute_process(
COMMAND
${CMAKE_COMMAND} -E touch "${CHECK_DONE_FILE}"
RESULTS_VARIABLE EV_RESULTS
)
endif()
message(STATUS "Using ${EV_PIP_INSTALL_LOCAL_PACKAGE_NAME} from ${CMAKE_CURRENT_SOURCE_DIR} version: ${EV_PIP_INSTALL_LOCAL_INSTALLED_PACKAGE_VERSION}")
endfunction()

0 comments on commit 19a1d96

Please sign in to comment.