Skip to content
Snippets Groups Projects
Verified Commit 428ace77 authored by Lars Bilke's avatar Lars Bilke
Browse files

[CMake] Create a virtualenv in build dir with Poetry.

parent 1f709b98
No related branches found
No related tags found
No related merge requests found
...@@ -61,11 +61,11 @@ endif() ...@@ -61,11 +61,11 @@ endif()
option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF)
# ---- CMake includes ---- # ---- CMake includes ----
include(Versions)
include(PreFind) include(PreFind)
include(SubmoduleSetup) include(SubmoduleSetup)
include(ProcessesSetup) include(ProcessesSetup)
include(ProjectSetup) include(ProjectSetup)
include(Versions)
include(Functions) include(Functions)
include(ConanSetup) include(ConanSetup)
include(CompilerSetup) include(CompilerSetup)
......
...@@ -6,7 +6,7 @@ if(DEFINED ENV{OGS_VERSION}) ...@@ -6,7 +6,7 @@ if(DEFINED ENV{OGS_VERSION})
message(STATUS "OGS VERSION: ${OGS_VERSION} (set via environment)") message(STATUS "OGS VERSION: ${OGS_VERSION} (set via environment)")
endif() endif()
if(NOT IS_GIT_REPO) if(NOT IS_GIT_REPO AND NOT OGS_VERSION)
execute_process(COMMAND ${GIT_EXECUTABLE} status execute_process(COMMAND ${GIT_EXECUTABLE} status
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE IS_GIT_REPO RESULT_VARIABLE IS_GIT_REPO
...@@ -26,7 +26,7 @@ if(NOT IS_GIT_REPO) ...@@ -26,7 +26,7 @@ if(NOT IS_GIT_REPO)
endif() endif()
endif() endif()
if(IS_GIT_REPO) if(IS_GIT_REPO AND NOT OGS_VERSION)
# Get version info from Git, implementation based on # Get version info from Git, implementation based on
# https://github.com/tomtom-international/cpp-dependencies # https://github.com/tomtom-international/cpp-dependencies
execute_process( execute_process(
...@@ -84,8 +84,31 @@ if(IS_GIT_REPO) ...@@ -84,8 +84,31 @@ if(IS_GIT_REPO)
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
endif() endif()
### Python setup ###
find_program(POETRY poetry)
if(POETRY)
configure_file(${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml
${PROJECT_BINARY_DIR}/poetry.toml COPYONLY)
if(NOT EXISTS ${PROJECT_BINARY_DIR}/pyproject.toml)
configure_file(${PROJECT_SOURCE_DIR}/scripts/python/pyproject.in.toml
${PROJECT_BINARY_DIR}/pyproject.toml)
endif()
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv)
execute_process(
COMMAND ${POETRY} install
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
endif()
set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv)
endif()
if(OGS_USE_PYTHON) if(OGS_USE_PYTHON)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED) find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter Development REQUIRED)
else() else()
find_package(Python3 COMPONENTS Interpreter) find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter)
endif()
if(POETRY)
set(Python3_VIRTUALENV_SITEPACKAGES
${Python3_ROOT_DIR}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages)
endif() endif()
[virtualenvs]
in-project = true
[tool.poetry]
name = "ogs-build"
version = "@OGS_VERSION@" # is written just once, maybe outdated
description = "CMake auto-generated"
authors = [""]
[tool.poetry.dependencies]
python = "^@ogs.minimum_version.python@, <3.9" # TODO: <3.9 is a tespy requirement
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
"eigen": "3.3.4", "eigen": "3.3.4",
"vtk": "8.1.2", "vtk": "8.1.2",
"petsc": "3.11.2", "petsc": "3.11.2",
"qt": "5.12.4" "qt": "5.12.4",
"python": "3.7"
}, },
"tested_version": { "tested_version": {
"vtk": "8.2.0", "vtk": "8.2.0",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment