From 34d0b10e302dfe6dedae46cab72049697b0aefae Mon Sep 17 00:00:00 2001 From: Andreas Heinrich Date: Fri, 14 Jun 2024 09:55:12 +0200 Subject: [PATCH] Use CMake Python Functions (#188) * Use cmake python functions defined in everest-cmake Signed-off-by: Andreas Heinrich * fix python venv setup Signed-off-by: Andreas Heinrich * Fix add_subdirectory Signed-off-by: Andreas Heinrich * bump version Signed-off-by: Andreas Heinrich --------- Signed-off-by: Andreas Heinrich --- CMakeLists.txt | 9 ++++++- everestpy/CMakeLists.txt | 36 ++++++++++------------------ everestpy/src/everest/CMakeLists.txt | 6 ----- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e102aac3..ff332d6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.14) project(everest-framework - VERSION 0.15.0 + VERSION 0.15.1 DESCRIPTION "The open operating system for e-mobility charging stations" LANGUAGES CXX C ) @@ -20,6 +20,13 @@ option(EVEREST_ENABLE_PY_SUPPORT "Enable everestpy for Python modules" ON) option(EVEREST_ENABLE_RS_SUPPORT "Enable everestrs for Rust modules" OFF) option(EVEREST_ENABLE_ADMIN_PANEL_BACKEND "Enable everest admin panel backend" ON) option(EVEREST_INSTALL_ADMIN_PANEL "Download and install everest admin panel" ON) +ev_setup_cmake_variables_python_wheel() +option(${PROJECT_NAME}_USE_PYTHON_VENV "Use python venv for pip install targets" OFF) +set(${PROJECT_NAME}_PYTHON_VENV_PATH "${CMAKE_BINARY_DIR}/venv" CACHE PATH "Path to python venv") +ev_setup_python_executable( + USE_PYTHON_VENV ${${PROJECT_NAME}_USE_PYTHON_VENV} + PYTHON_VENV_PATH ${${PROJECT_NAME}_PYTHON_VENV_PATH} +) # make own cmake modules available list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/everestpy/CMakeLists.txt b/everestpy/CMakeLists.txt index bcc08f8d..bdd5bd64 100644 --- a/everestpy/CMakeLists.txt +++ b/everestpy/CMakeLists.txt @@ -1,29 +1,17 @@ -add_subdirectory(src/everest) - -add_custom_target(everestpy_pip_install_dist - # remove build dir from pip - COMMAND - cmake -E remove_directory build - COMMAND - ${PYTHON_EXECUTABLE} -m pip install --force-reinstall . - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS +ev_create_pip_install_targets( + PACKAGE_NAME + everestpy + DIST_DEPENDS everestpy_ln_dist - COMMENT - "Installing everestpy from distribution" + LOCAL_DEPENDS + everestpy_ln_local ) -add_custom_target(everestpy_pip_install_local - # remove build dir from pip - COMMAND - cmake -E remove_directory build - COMMAND - ${PYTHON_EXECUTABLE} -m pip install --force-reinstall -e . - WORKING_DIRECTORY - ${CMAKE_CURRENT_SOURCE_DIR} +ev_create_python_wheel_targets( + PACKAGE_NAME + everestpy DEPENDS - everestpy_ln_local - COMMENT - "Installing everestpy via user-mode from build" + everestpy_ln_dist ) + +add_subdirectory(src/everest) diff --git a/everestpy/src/everest/CMakeLists.txt b/everestpy/src/everest/CMakeLists.txt index eb5db72d..515d5009 100644 --- a/everestpy/src/everest/CMakeLists.txt +++ b/everestpy/src/everest/CMakeLists.txt @@ -1,9 +1,3 @@ -find_program( - PYTHON_EXECUTABLE - python3 - REQUIRED -) - if (DISABLE_EDM) find_package(pybind11 REQUIRED) find_package(pybind11_json REQUIRED)