Skip to content
Snippets Groups Projects
Commit 3b5b4798 authored by Christoph Alt's avatar Christoph Alt
Browse files

Added a default installation of pystencils/pystencilssfg if no

requirements.txt is present
parent de708107
No related merge requests found
Pipeline #74034 passed with stages
in 2 minutes and 31 seconds
...@@ -27,7 +27,7 @@ if(NOT DEFINED CACHE{PystencilsSfg_PYTHON_INTERPRETER}) ...@@ -27,7 +27,7 @@ if(NOT DEFINED CACHE{PystencilsSfg_PYTHON_INTERPRETER})
set( _sfg_cache_python_init ${PystencilsSfg_PYTHON_PATH} ) set( _sfg_cache_python_init ${PystencilsSfg_PYTHON_PATH} )
elseif (CODEGEN_PRIVATE_VENV) elseif (CODEGEN_PRIVATE_VENV)
# ... or create own venv ... # ... or create an own venv ...
set(CODEGEN_VENV_PATH ${CMAKE_CURRENT_BINARY_DIR}/codegen-venv CACHE PATH "Location of the virtual environment used for code generation") set(CODEGEN_VENV_PATH ${CMAKE_CURRENT_BINARY_DIR}/codegen-venv CACHE PATH "Location of the virtual environment used for code generation")
set(_venv_python_exe ${CODEGEN_VENV_PATH}/bin/python) set(_venv_python_exe ${CODEGEN_VENV_PATH}/bin/python)
...@@ -44,14 +44,26 @@ if(NOT DEFINED CACHE{PystencilsSfg_PYTHON_INTERPRETER}) ...@@ -44,14 +44,26 @@ if(NOT DEFINED CACHE{PystencilsSfg_PYTHON_INTERPRETER})
) )
endif() endif()
message( STATUS "Installing required Python packages..." )
set(CODEGEN_VENV_REQUIREMENTS ${PROJECT_SOURCE_DIR}/requirements.txt CACHE PATH "Location of the requirements installed in the virtual environment used for code generation") set(CODEGEN_VENV_REQUIREMENTS ${PROJECT_SOURCE_DIR}/requirements.txt CACHE FILEPATH "Location of the requirements installed in the virtual environment used for code generation")
execute_process( if (EXISTS ${CODEGEN_VENV_REQUIREMENTS})
COMMAND ${_venv_python_exe} -m pip install -r ${CODEGEN_VENV_REQUIREMENTS} message( STATUS "Installing required Python packages from ${CODEGEN_VENV_REQUIREMENTS}" )
OUTPUT_QUIET execute_process( COMMAND ${_venv_python_exe} -m pip install -r ${CODEGEN_VENV_REQUIREMENTS} OUTPUT_QUIET)
) else()
#TODO automatically install pystencilssfg/pystencils set(Pystencils_URL "git+https://i10git.cs.fau.de/pycodegen/pystencils.git@v2.0-dev" CACHE STRING "Location of pystencils to installed in the virtual environment used for code generation")
set(PystencilsSfg_URL "git+https://i10git.cs.fau.de/pycodegen/pystencils-sfg.git" CACHE STRING "Location of pystencils-sfg to installed in the virtual environment used for code generation")
message( STATUS "Installing required Pystencils from ${Pystencils_URL}" )
execute_process(
COMMAND ${_venv_python_exe} -m pip install "${Pystencils_URL}"
OUTPUT_QUIET
)
message( STATUS "Installing required Pystencils-sfg from ${PystencilsSfg_URL}" )
execute_process(
COMMAND ${_venv_python_exe} -m pip install "${PystencilsSfg_URL}"
OUTPUT_QUIET
)
endif()
set( _sfg_private_venv_done TRUE CACHE BOOL "" ) set( _sfg_private_venv_done TRUE CACHE BOOL "" )
mark_as_advanced(_sfg_private_venv_done) mark_as_advanced(_sfg_private_venv_done)
......
...@@ -18,7 +18,7 @@ def test_cmake_project(tmp_path, config_source): ...@@ -18,7 +18,7 @@ def test_cmake_project(tmp_path, config_source):
result = subprocess.run(obtain_find_module_cmd, cwd=CMAKE_PROJECT_DIR) result = subprocess.run(obtain_find_module_cmd, cwd=CMAKE_PROJECT_DIR)
assert result.returncode == 0 assert result.returncode == 0
cmake_configure_cmd = ["cmake", "-S", CMAKE_PROJECT_DIR, "-B", str(tmp_path)] cmake_configure_cmd = ["cmake", "-S", CMAKE_PROJECT_DIR, "-B", str(tmp_path), "-DCODEGEN_PRIVATE_VENV=OFF"]
if config_source is not None: if config_source is not None:
cmake_configure_cmd.append(f"-D{config_source}=ON") cmake_configure_cmd.append(f"-D{config_source}=ON")
configure_result = subprocess.run(cmake_configure_cmd) configure_result = subprocess.run(cmake_configure_cmd)
...@@ -49,3 +49,14 @@ def test_cmake_project(tmp_path, config_source): ...@@ -49,3 +49,14 @@ def test_cmake_project(tmp_path, config_source):
custom_dir_output = tmp_path / "my-output" / "CustomDirTest.hpp" custom_dir_output = tmp_path / "my-output" / "CustomDirTest.hpp"
assert custom_dir_output.exists() assert custom_dir_output.exists()
assert "#define NOTHING" in custom_dir_output.read_text() assert "#define NOTHING" in custom_dir_output.read_text()
def test_cmake_project_autoinstall(tmp_path):
obtain_find_module_cmd = ["sfg-cli", "cmake", "make-find-module"]
result = subprocess.run(obtain_find_module_cmd, cwd=CMAKE_PROJECT_DIR)
assert result.returncode == 0
cmake_configure_cmd = ["cmake", "-S", CMAKE_PROJECT_DIR, "-B", str(tmp_path), "-DCODEGEN_PRIVATE_VENV=ON"]
configure_result = subprocess.run(cmake_configure_cmd)
assert configure_result.returncode == 0
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment