diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d74fc66b444486aa93603afa3149e8ff476af36..13b429b2fb7d337f88a1b6286630a3c112cc37ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,11 +61,11 @@ endif() option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) # ---- CMake includes ---- +include(Versions) include(PreFind) include(SubmoduleSetup) include(ProcessesSetup) include(ProjectSetup) -include(Versions) include(Functions) include(ConanSetup) include(CompilerSetup) diff --git a/scripts/cmake/PreFind.cmake b/scripts/cmake/PreFind.cmake index 308323a35d7f31ead167c31d2405c00e8d755e0d..e49e011034ec3e743bf52558024c2e0f79fbeaa4 100644 --- a/scripts/cmake/PreFind.cmake +++ b/scripts/cmake/PreFind.cmake @@ -6,7 +6,7 @@ if(DEFINED ENV{OGS_VERSION}) message(STATUS "OGS VERSION: ${OGS_VERSION} (set via environment)") endif() -if(NOT IS_GIT_REPO) +if(NOT IS_GIT_REPO AND NOT OGS_VERSION) execute_process(COMMAND ${GIT_EXECUTABLE} status WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE IS_GIT_REPO @@ -26,7 +26,7 @@ if(NOT IS_GIT_REPO) endif() endif() -if(IS_GIT_REPO) +if(IS_GIT_REPO AND NOT OGS_VERSION) # Get version info from Git, implementation based on # https://github.com/tomtom-international/cpp-dependencies execute_process( @@ -84,8 +84,31 @@ if(IS_GIT_REPO) OUTPUT_STRIP_TRAILING_WHITESPACE ) 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) - find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter Development REQUIRED) 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() diff --git a/scripts/python/poetry.in.toml b/scripts/python/poetry.in.toml new file mode 100644 index 0000000000000000000000000000000000000000..ab1033bd37224ee84b5862fb25f094db73809b74 --- /dev/null +++ b/scripts/python/poetry.in.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/scripts/python/pyproject.in.toml b/scripts/python/pyproject.in.toml new file mode 100644 index 0000000000000000000000000000000000000000..0b6bb77dbe4159e826e1be0a682ec4ffd847188f --- /dev/null +++ b/scripts/python/pyproject.in.toml @@ -0,0 +1,14 @@ +[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" diff --git a/web/data/versions.json b/web/data/versions.json index 7d7298131316a1bb51aa9c2463066bf019ed9097..66796e47d7e95c9ca946840d3747d8a1f150a250 100644 --- a/web/data/versions.json +++ b/web/data/versions.json @@ -16,7 +16,8 @@ "eigen": "3.3.4", "vtk": "8.1.2", "petsc": "3.11.2", - "qt": "5.12.4" + "qt": "5.12.4", + "python": "3.7" }, "tested_version": { "vtk": "8.2.0",