Skip to content
Snippets Groups Projects
Commit c9f8e8a0 authored by Christoph Alt's avatar Christoph Alt Committed by Frederik Hennig
Browse files

Adding option to automatically installation

parent dcb77258
Branches
1 merge request!20Adding option to automatically installation
......@@ -71,3 +71,12 @@ pages:
- docker
only:
- master@pycodegen/pystencils-sfg
cmake-standalone:
stage: deploy
needs: []
script:
- echo "Publishing Cmake standalone"
artifacts:
paths:
- standalone
......@@ -48,7 +48,7 @@ endif()
if(${PystencilsSfg_FOUND})
message( STATUS "Found pystencils Source File Generator (Version ${PystencilsSfg_VERSION})")
message( STATUS "Using Python interpreter ${PystencilsSfg_PYTHON_INTERPRETER} for SFG generator scripts.")
execute_process(COMMAND ${PystencilsSfg_PYTHON_INTERPRETER} -m pystencilssfg cmake modulepath --no-newline
OUTPUT_VARIABLE _PystencilsSfg_CMAKE_MODULE_PATH)
......
cmake_minimum_required( VERSION 3.24 )
project(PystencilsSfg_Standalone)
if (DEFINED CACHE{PystencilsSfg_PYTHON_INTERPRETER})
set( _use_venv_init OFF)
elseif(DEFINED PystencilsSfg_PYTHON_PATH)
set( _use_venv_init OFF)
else()
set( _use_venv_init ON )
endif()
set(CODEGEN_PRIVATE_VENV ${_use_venv_init}
CACHE BOOL
"Create a private virtual Python environment inside the build tree for code generation"
)
function(codegen_venv_install)
if(NOT CODEGEN_PRIVATE_VENV)
return()
endif()
if(NOT _sfg_private_venv_done)
message( FATAL_ERROR "The private virtual environment for code generation was not initialized yet" )
endif()
execute_process(
COMMAND ${PystencilsSfg_PYTHON_INTERPRETER} -m pip install ${ARGV}
)
endfunction()
if (CODEGEN_PRIVATE_VENV)
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(CODEGEN_VENV_PYTHON ${_venv_python_exe})
find_package( Python COMPONENTS Interpreter REQUIRED )
if(NOT _sfg_private_venv_done)
message( STATUS "Setting up Python virtual environment at ${CODEGEN_VENV_PATH}" )
# Create the venv and register its interpreter with pystencils-sfg
if(NOT EXISTS ${CODEGEN_VENV_PATH})
execute_process( COMMAND ${Python_EXECUTABLE} -m venv ${CODEGEN_VENV_PATH})
endif()
set(CODEGEN_VENV_REQUIREMENTS ${PROJECT_SOURCE_DIR}/requirements.txt CACHE FILEPATH "Location of the requirements installed in the virtual environment used for code generation")
if (EXISTS ${CODEGEN_VENV_REQUIREMENTS})
message( STATUS "Installing required Python packages from ${CODEGEN_VENV_REQUIREMENTS}" )
execute_process( COMMAND ${_venv_python_exe} -m pip install -r ${CODEGEN_VENV_REQUIREMENTS} OUTPUT_QUIET)
else()
message( WARNING "Could not find ${CODEGEN_VENV_REQUIREMENTS}" )
endif()
set( _sfg_private_venv_done TRUE CACHE BOOL "" )
mark_as_advanced(_sfg_private_venv_done)
endif()
set(_sfg_cache_python_init ${_venv_python_exe})
set(PystencilsSfg_PYTHON_INTERPRETER ${_sfg_cache_python_init} CACHE PATH "Path to the Python executable used to run pystencils-sfg")
endif()
# get the find pystencils-sfg file
execute_process(
COMMAND ${PystencilsSfg_PYTHON_INTERPRETER} -m pystencilssfg cmake make-find-module
WORKING_DIRECTORY ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}
)
# renaming it
file(RENAME ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/FindPystencilsSfg.cmake ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/pystencilssfg-config.cmake)
# Find it
find_package( PystencilsSfg REQUIRED )
py-cpuinfo
# pystencils 2.0 Development Branch
git+https://i10git.cs.fau.de/pycodegen/pystencils.git@4876f0b774d38fe7644f2b64f80f1291ffa0fa08
# pystencils-sfg
git+https://i10git.cs.fau.de/pycodegen/pystencils-sfg.git@dcb77258670abe5bc87f2bd80761594eb304cb90
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