Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track version of installed python packages #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.5.1)
set(PACKAGE_VERSION 0.6.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 "5")
if (PACKAGE_FIND_VERSION_MINOR GREATER "6")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
else ()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
Expand Down
42 changes: 40 additions & 2 deletions python-package-helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ function(ev_install_pip_package)
)
endfunction()

function(ev_get_python_package_version)
set(oneValueArgs
PACKAGE_SOURCE_DIRECTORY
VERSION_OUTPUT
)
cmake_parse_arguments(
"arg"
""
"${oneValueArgs}"
""
${ARGN}
)
if("${arg_PACKAGE_SOURCE_DIRECTORY}" STREQUAL "")
message(FATAL_ERROR "PACKAGE_SOURCE_DIRECTORY is required")
endif()

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

string(REGEX MATCH "^[0-9]+\\.[0-9]+(\\.[0-9]+)?" "PACKAGE_VERSION" "${PACKAGE_VERSION}")

set("${arg_VERSION_OUTPUT}" "${PACKAGE_VERSION}" PARENT_SCOPE)
endfunction()

function(ev_create_pip_install_dist_target)
set(oneValueArgs
PACKAGE_NAME
Expand All @@ -100,12 +131,19 @@ function(ev_create_pip_install_dist_target)
message(STATUS "ev_create_pip_install_dist_target: no PACKAGE_SOURCE_DIRECTORY provided, using: ${arg_PACKAGE_SOURCE_DIRECTORY}")
endif()

set(CHECK_DONE_FILE "${CMAKE_BINARY_DIR}/${arg_PACKAGE_NAME}_pip_install_dist_installed")
ev_get_python_package_version(
PACKAGE_SOURCE_DIRECTORY
${arg_PACKAGE_SOURCE_DIRECTORY}
VERSION_OUTPUT
"PACKAGE_VERSION"
)

set(CHECK_DONE_FILE "${CMAKE_BINARY_DIR}/${arg_PACKAGE_NAME}_pip_install_dist_installed_${PACKAGE_VERSION}")
add_custom_command(
OUTPUT
"${CHECK_DONE_FILE}"
COMMENT
"Installing ${arg_PACKAGE_NAME} from distribution"
"Installing ${arg_PACKAGE_NAME} from distribution, version: ${PACKAGE_VERSION}"
WORKING_DIRECTORY
${arg_PACKAGE_SOURCE_DIRECTORY}

Expand Down