diff --git a/CMakeLists.txt b/CMakeLists.txt index 2205a7b9ce9d779b4602badb8a3077774f1af0b3..7c86ed45bb3872abf57a5ab814d48895c1ba3fca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,9 +39,7 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) ) endif() option(OGS_USE_PYTHON "Interface with Python" ON) -option(OGS_USE_POETRY - "Enables automatic Python virtual environment handling with poetry." ON -) +option(OGS_USE_PIP "Enables automatic Python virtual environment handling." ON) cmake_dependent_option( OGS_BUILD_SWMM "Should the SWMM interface be built?" ON "WIN32" OFF ) @@ -244,7 +242,7 @@ endif() include(UnityBuildSettings) -if(POETRY) +if(OGS_USE_PIP) # Caches a hash of requested Python packages when they were successfully # installed. On subsequent runs compare new hash to cached. If equal do # nothing. @@ -259,10 +257,16 @@ if(POETRY) if(NOT ${_ogs_python_packages_sha1} STREQUAL "${_OGS_PYTHON_PACKAGES_SHA1}" AND ${OGS_PYTHON_PACKAGES_LENGTH} GREATER 0 ) + string(REPLACE ";" "\n" REQUIREMENTS_CONTENT "${OGS_PYTHON_PACKAGES}") + file(WRITE ${PROJECT_BINARY_DIR}/requirements.txt + ${REQUIREMENTS_CONTENT} + ) execute_process( - COMMAND ${CMD_COMMAND} poetry add ${OGS_PYTHON_PACKAGES} + COMMAND ${LOCAL_VIRTUALENV_BIN_DIR}/pip install -r requirements.txt WORKING_DIRECTORY ${PROJECT_BINARY_DIR} RESULT_VARIABLE _return_code + OUTPUT_VARIABLE _out + ERROR_VARIABLE _err ) if(${_return_code} EQUAL 0) set(_OGS_PYTHON_PACKAGES_SHA1 "${_ogs_python_packages_sha1}" @@ -271,8 +275,8 @@ if(POETRY) else() message( FATAL_ERROR - "Installation of Python packages via poetry failed!\n" - "To disable poetry set OGS_USE_POETRY=OFF." + "Installation of Python packages via pip failed!\n" + "To disable pip set OGS_USE_PIP=OFF.\n\n${_out}\n${_err}" ) endif() endif() diff --git a/ProcessLib/HeatTransportBHE/Tests.cmake b/ProcessLib/HeatTransportBHE/Tests.cmake index 781904a21323a17e39ca7858646afd37c1e821c0..a06e0d4151a3e41f12efe141f322fb4460741d91 100644 --- a/ProcessLib/HeatTransportBHE/Tests.cmake +++ b/ProcessLib/HeatTransportBHE/Tests.cmake @@ -92,7 +92,7 @@ if("${Python3_VERSION}" VERSION_LESS 3.9) WRAPPER time TESTER vtkdiff REQUIREMENTS OGS_USE_PYTHON AND NOT OGS_USE_MPI - PYTHON_PACKAGES "TESPy=0.3.2" + PYTHON_PACKAGES "TESPy==0.3.2" DIFF_DATA 3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_soil temperature_soil 1e-12 1e-13 3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 1e-10 1e-13 @@ -124,7 +124,7 @@ if("${Python3_VERSION}" VERSION_LESS 3.9) WRAPPER time TESTER vtkdiff REQUIREMENTS OGS_USE_PYTHON AND NOT OGS_USE_MPI - PYTHON_PACKAGES "TESPy=0.3.2" + PYTHON_PACKAGES "TESPy==0.3.2" DIFF_DATA 3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_soil temperature_soil 1e-12 1e-13 3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 1e-9 1e-12 diff --git a/Tests/Data/Parabolic/T/3D_3BHEs_array/README.md b/Tests/Data/Parabolic/T/3D_3BHEs_array/README.md index 92f79b19686a7aa8693be2154aa99e3ff992917d..ea5fe1ad2500d7eeefaccf3c623726fd0a9c2a11 100644 --- a/Tests/Data/Parabolic/T/3D_3BHEs_array/README.md +++ b/Tests/Data/Parabolic/T/3D_3BHEs_array/README.md @@ -1,5 +1,3 @@ # How to run - You need to have [poetry][1] installed and build OGS with `OGS_USE_PYTHON=ON`. - - [1]: https://python-poetry.org + You need to configure OGS with `-DOGS_USE_PYTHON=ON -DOGS_USE_PIP=ON`. diff --git a/scripts/cmake/ConanSetup.cmake b/scripts/cmake/ConanSetup.cmake index 13059c90606021255b4324407c2d308743bff004..1f40215387cc3cedf661512d8381d06866d649fa 100644 --- a/scripts/cmake/ConanSetup.cmake +++ b/scripts/cmake/ConanSetup.cmake @@ -1,16 +1,7 @@ if(NOT OGS_USE_CONAN OR NOT OGS_USE_NETCDF) return() endif() -string(TOLOWER ${OGS_USE_CONAN} OGS_USE_CONAN_lower) -if(OGS_USE_CONAN_lower STREQUAL "auto" AND POETRY) - execute_process(COMMAND ${CMD_COMMAND} poetry add conan==${ogs.minimum_version.conan} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) - find_program(CONAN_CMD conan HINTS ${LOCAL_VIRTUALENV_BIN_DIR} - REQUIRED NO_DEFAULT_PATH - ) -else() - find_program(CONAN_CMD conan) -endif() +find_program(CONAN_CMD conan) if(NOT CONAN_CMD AND OGS_USE_NETCDF) message(WARNING "conan executable not found. Specify CMake option " "OGS_USE_CONAN=auto for automatic installation in the build directory " diff --git a/scripts/cmake/Coverage.cmake b/scripts/cmake/Coverage.cmake index 1cd6d9383978b1e704ba20edbca4124e2eb906a5..b860986c0f921167e78f6df86260574c827bfbd3 100644 --- a/scripts/cmake/Coverage.cmake +++ b/scripts/cmake/Coverage.cmake @@ -1,6 +1,8 @@ find_program(FASTCOV_PATH NAMES fastcov fastcov.py) -if(NOT FASTCOV_PATH AND NOT POETRY) - message(FATAL_ERROR "Code coverage requires either fastcov or poetry.") +if(NOT FASTCOV_PATH AND NOT OGS_USE_PIP) + message( + FATAL_ERROR "Code coverage requires either fastcov or OGS_USE_PIP=ON." + ) endif() # https://github.com/linux-test-project/lcov/pull/125 @@ -17,25 +19,20 @@ include(CodeCoverage) append_coverage_compiler_flags() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og") +# cmake-lint: disable=C0103 if(NOT FASTCOV_PATH) - execute_process( - COMMAND ${CMD_COMMAND} poetry add fastcov==1.10 - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - ) - find_program( - FASTCOV_PATH - NAMES fastcov - HINTS ${LOCAL_VIRTUALENV_BIN_DIR} REQUIRED - NO_DEFAULT_PATH - ) + list(APPEND OGS_PYTHON_PACKAGES "fastcov==1.14") + set(FASTCOV_PATH ${LOCAL_VIRTUALENV_BIN_DIR}/fastcov CACHE INTERNAL "") endif() if(DEFINED ENV{CI}) set(COVERAGE_ADDITIONAL_ARGS SKIP_HTML) endif() +# ~~~ # TODO: segfault in MeshLibMappedPropertyVector.Double|Int # TODO: segfault in TestVtkMeshConverter.Conversion +# ~~~ setup_target_for_coverage_fastcov( NAME testrunner_coverage diff --git a/scripts/cmake/PythonSetup.cmake b/scripts/cmake/PythonSetup.cmake index 180cb4de7e1adec889578efbdb3f09658c625b60..3f642e0d3bf36269894b3755d95949ea7e9a3776 100644 --- a/scripts/cmake/PythonSetup.cmake +++ b/scripts/cmake/PythonSetup.cmake @@ -2,65 +2,47 @@ # prefer unix location over frameworks (Apple-only) set(Python3_FIND_FRAMEWORK LAST) -if(OGS_USE_POETRY) - find_program(POETRY poetry) - # See web/content/docs/devguide/packages/python-env.md for docs on Poetry - if(POETRY) - set(OGS_PYTHON_PACKAGES "" - CACHE INTERNAL - "List of Python packages to be installed via poetry." +if(OGS_USE_PIP) + set(OGS_PYTHON_PACKAGES "" + CACHE INTERNAL "List of Python packages to be installed via pip." + ) + set(Python3_FIND_STRATEGY VERSION) + find_package( + Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter REQUIRED + ) + + if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) + execute_process( + COMMAND ${Python3_EXECUTABLE} -m venv .venv + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) - set(Python3_FIND_STRATEGY VERSION) - find_package( - Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter - REQUIRED + unset(_OGS_PYTHON_PACKAGES_SHA1 CACHE) + endif() + set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) + if(MSVC) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) + set(LOCAL_VIRTUALENV_BIN_DIR ${PROJECT_BINARY_DIR}/.venv/Scripts + CACHE INTERNAL "" ) - configure_file( - ${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml - ${PROJECT_BINARY_DIR}/poetry.toml COPYONLY + else() + set(LOCAL_VIRTUALENV_BIN_DIR ${PROJECT_BINARY_DIR}/.venv/bin + CACHE INTERNAL "" ) - 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 ${CMD_COMMAND} poetry env use ${Python3_EXECUTABLE} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - ) - execute_process( - COMMAND ${CMD_COMMAND} poetry install - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - ) - endif() - set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) - if(MSVC) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) - set(LOCAL_VIRTUALENV_BIN_DIR ${PROJECT_BINARY_DIR}/.venv/Scripts - CACHE INTERNAL "" - ) - else() - set(LOCAL_VIRTUALENV_BIN_DIR ${PROJECT_BINARY_DIR}/.venv/bin - CACHE INTERNAL "" - ) - endif() - if(OGS_BUILD_TESTING) - # Notebook requirements from versions.json - foreach(var ${ogs.python.notebook_requirements}) - list(APPEND OGS_PYTHON_PACKAGES - "${ogs.python.notebook_requirements_${var}}" - ) - endforeach() + endif() + if(OGS_BUILD_TESTING) + # Notebook requirements from versions.json + foreach(var ${ogs.python.notebook_requirements}) list(APPEND OGS_PYTHON_PACKAGES - "snakemake=${ogs.minimum_version.snakemake}" - ) - set(SNAKEMAKE ${LOCAL_VIRTUALENV_BIN_DIR}/snakemake CACHE FILEPATH - "" FORCE + "${ogs.python.notebook_requirements_${var}}" ) - endif() + endforeach() + list(APPEND OGS_PYTHON_PACKAGES + "snakemake==${ogs.minimum_version.snakemake}" + ) + set(SNAKEMAKE ${LOCAL_VIRTUALENV_BIN_DIR}/snakemake CACHE FILEPATH "" + FORCE + ) endif() endif() @@ -72,7 +54,7 @@ if(OGS_USE_PYTHON) else() find_package(Python3 ${ogs.minimum_version.python} COMPONENTS Interpreter) endif() -if(POETRY) +if(OGS_USE_PIP) if(MSVC) file(TO_NATIVE_PATH "${Python3_ROOT_DIR}/Lib/site-packages" Python3_VIRTUALENV_SITEPACKAGES diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake index abd0be9197175545de6c9d9e91d0d2fca562705d..164011a7388ed4e37fb4b679a56839d3a5d40e6e 100644 --- a/scripts/cmake/test/AddTest.cmake +++ b/scripts/cmake/test/AddTest.cmake @@ -450,7 +450,7 @@ Use six arguments version of AddTest with absolute and relative tolerances" add_dependencies(ctest-large ${AddTest_EXECUTABLE}) if(AddTest_PYTHON_PACKAGES) - if(POETRY) + if(OGS_USE_PIP) # Info has to be passed by global property because it is not # possible to set cache variables from inside a function. set_property( @@ -463,7 +463,7 @@ Use six arguments version of AddTest with absolute and relative tolerances" "Warning: Benchmark ${AddTest_NAME} requires these " "Python packages: ${AddTest_PYTHON_PACKAGES}!\n Make sure to " "have them installed in your current Python environment OR " - "install the Poetry package manager for Python!" + "set OGS_USE_PIP=ON!" ) endif() endif() diff --git a/scripts/python/poetry.in.toml b/scripts/python/poetry.in.toml deleted file mode 100644 index 253c85a9f38f81eccd4a00686ccad8abe1d98dca..0000000000000000000000000000000000000000 --- a/scripts/python/poetry.in.toml +++ /dev/null @@ -1,6 +0,0 @@ -[virtualenvs] -in-project = true - -# https://github.com/python-poetry/poetry/issues/4210 -[experimental] -new-installer = false diff --git a/scripts/python/pyproject.in.toml b/scripts/python/pyproject.in.toml deleted file mode 100644 index f1e79914dd2f0aea3c3c5aea114326556f0efb62..0000000000000000000000000000000000000000 --- a/scripts/python/pyproject.in.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "ogs-build" -version = "@OGS_VERSION@" # is written just once, maybe outdated -description = "CMake auto-generated" -authors = [""] - -[tool.poetry.dependencies] -python = "@Python3_VERSION@" - -[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 8bb4f1b0b0a16ec85d613e2096bfbcec3d14ee5e..e4302ae1441ab28f54f23b3657e284e17a60f25b 100644 --- a/web/data/versions.json +++ b/web/data/versions.json @@ -36,13 +36,13 @@ }, "python": { "notebook_requirements": [ - "https://github.com/joergbuchwald/ogs6py/archive/0f9e738e2ee469c8bde4204b2151238973417694.zip", - "https://github.com/joergbuchwald/VTUinterface/archive/refs/heads/master.zip", - "https://github.com/bilke/nb2hugo/archive/e27dc02df2be1ce19e4a6f52d197c2e2a6ca520c.zip", + "git+https://github.com/joergbuchwald/ogs6py@0f9e738e2ee469c8bde4204b2151238973417694#egg=ogs6py", + "git+https://github.com/joergbuchwald/VTUinterface@master#egg=VTUinterface", + "git+https://github.com/bilke/nb2hugo@e27dc02df2be1ce19e4a6f52d197c2e2a6ca520c#egg=nb2hugo", "ipykernel==6.9.1", "nbconvert==6.4.0", "ipython_genutils==0.2.0", - "pillow=9.0.0" + "pillow==9.0.0" ] }, "cpm": {