Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
002fbf2
set install directories depending on target type
matekelemen Jun 12, 2025
759cebe
set rpath for tests
matekelemen Jun 13, 2025
f93139e
set rpath for python bindings
matekelemen Jun 13, 2025
ebc5450
set install dirs of the C lib
matekelemen Jun 13, 2025
b5083ba
set install dirs of the fortran lib
matekelemen Jun 13, 2025
4f95257
update python and library paths in the CI
matekelemen Jun 13, 2025
b196a53
set c mpi lib install path
matekelemen Jun 13, 2025
ca8c4af
fix python binary module install paths and rpaths
matekelemen Jun 13, 2025
4e452ba
update PYTHONPATH for the windows CI
matekelemen Jun 13, 2025
d768f34
Revert "update PYTHONPATH for the windows CI"
matekelemen Jun 13, 2025
2fae258
debug print
matekelemen Jun 13, 2025
8e7decd
remove direct compiler flags specifying the cpp standard
matekelemen May 28, 2026
907b44f
update pybind11 to version 3.0.4
matekelemen May 28, 2026
1b25f14
ignore clangd configuration
matekelemen May 28, 2026
716b88f
pybind11::module => pybind11::module_
matekelemen May 28, 2026
aa95aec
wrap python bindings of iterator ranges into pybind11::cpp_functions …
matekelemen May 28, 2026
ff43eec
explicit template argument for pybind11 holder type
matekelemen May 28, 2026
8d55983
debug
matekelemen May 28, 2026
97ccb9a
indicate which version of python is used for running tests on rocky
matekelemen May 28, 2026
6b3810e
/ => \ on windows
matekelemen May 28, 2026
cd0db17
install on rocky before running tests
matekelemen May 28, 2026
499c674
point PYTHONPATH to the install dir on windows
matekelemen May 28, 2026
4a4c542
the rocky docker image relies on /etc/bashrc??
matekelemen May 29, 2026
2576d2e
special treatment for pybind modules on windows
matekelemen May 29, 2026
17c3919
kratos' rocky image needs /etc/local/bin, try sourcing /etc/profile i…
matekelemen May 29, 2026
eef894d
sh => bash
matekelemen May 29, 2026
c0d1b51
give up on sourcing the fucking profile and extend PATH manually
matekelemen May 29, 2026
f984b40
maybe the rocky image got silently updated?w
matekelemen May 29, 2026
a92f1b7
yes, the rocky image did get silently updated, and python3.8 was repl…
matekelemen May 29, 2026
ea5dad4
drop intel mpi from the CI
matekelemen May 29, 2026
7de8b2b
trigger CI
matekelemen Jun 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
63 changes: 31 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ jobs:
fail-fast: false
matrix:
compiler: [GCC, CLANG, ICPX]
mpi: [OpenMPI, IntelMPI]
exclude:
# CLANG is not properly supported by Intel, better use LLVMIntel in the future
- compiler: CLANG
mpi: IntelMPI
mpi: [OpenMPI]
timeout-minutes: 30

steps:
Expand Down Expand Up @@ -74,21 +70,15 @@ jobs:
exit 1
fi

if [ ${{ matrix.compiler }} = ICPX ] || [ ${{ matrix.mpi }} = IntelMPI ]; then
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi

build_mpi_comm=OFF
if [ ${{ matrix.mpi }} = IntelMPI ]; then
build_mpi_comm=ON
fi

cmake -H"." -B"build" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCO_SIM_IO_BUILD_C=ON \
-DCO_SIM_IO_BUILD_FORTRAN=OFF \
-DCO_SIM_IO_BUILD_MPI=ON \
-DCO_SIM_IO_BUILD_MPI_COMMUNICATION=$build_mpi_comm \
-DCO_SIM_IO_STRICT_COMPILER=ON

cmake --build "build" --target install -- -j2
Expand All @@ -98,9 +88,9 @@ jobs:
OMPI_MCA_rmaps_base_oversubscribe: 1 # Allow oversubscription for MPI (needed for OpenMPI >= 3.0)
run: |
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PATH=${PATH}:${GITHUB_WORKSPACE}/bin # required for IntelMPI
export PATH=${PATH}:${GITHUB_WORKSPACE}/bin/tests_c_mpi # required for IntelMPI
if [ ${{ matrix.compiler }} = ICPX ] || [ ${{ matrix.mpi }} = IntelMPI ]; then
export PATH=${PATH}:${GITHUB_WORKSPACE}/bin
export PATH=${PATH}:${GITHUB_WORKSPACE}/bin/tests_c_mpi
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi

Expand Down Expand Up @@ -166,8 +156,8 @@ jobs:
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand All @@ -177,8 +167,8 @@ jobs:
if [ ${{ matrix.compiler }} = ICPX ]; then
source /opt/intel/oneapi/setvars.sh
fi
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
#TODO run the tests...
# TODO delete build dir to make sure the linking etc works correctly?
Expand Down Expand Up @@ -237,8 +227,8 @@ jobs:

- name: Running tests
run: |
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/libs
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand Down Expand Up @@ -314,12 +304,13 @@ jobs:
set CC=cl.exe
set CXX=cl.exe

cmake ^
-G"Visual Studio 17 2022" ^
-H"." ^
-B"build" ^
-DCO_SIM_IO_BUILD_PYTHON=ON ^
-DCO_SIM_IO_STRICT_COMPILER=ON || goto :error
cmake ^
-G"Visual Studio 17 2022" ^
-H"." ^
-B"build" ^
-DCO_SIM_IO_BUILD_PYTHON=ON ^
-DCO_SIM_IO_STRICT_COMPILER=ON ^
-DCMAKE_INSTALL_PREFIX=install || goto :error

cmake --build "build" --target install -- /p:Platform=x64 || goto :error

Expand All @@ -334,7 +325,11 @@ jobs:
PYTHON_CMD: python # for the tests (subprocess)
shell: cmd
run: |
set PYTHONPATH=%PYTHONPATH%;%GITHUB_WORKSPACE%/bin
set PYTHONPATH=%PYTHONPATH%;%GITHUB_WORKSPACE%\install\bin

@REM show what's on your PYTHONPATH
dir %GITHUB_WORKSPACE%\install\bin

cd tests
rem TODO delete build dir to make sure the linking etc works correctly?
python run_python_tests.py
Expand All @@ -353,27 +348,31 @@ jobs:

- name: Build CoSimIO
run: |
export PATH="$PATH:/usr/local/bin"
cmake -H"." -B"build" \
-DCMAKE_BUILD_TYPE="Debug" \
-DCO_SIM_IO_BUILD_C=ON \
-DCO_SIM_IO_BUILD_PYTHON=ON \
-DCO_SIM_IO_STRICT_COMPILER=ON \
-DPYTHON_EXECUTABLE=/usr/local/bin/python3.8
-DCMAKE_INSTALL_PREFIX=install \
-DPython_EXECUTABLE=$(which python3.10)

cmake --build "build" --target install -- -j2

- name: Running tests (Ctest)
run: |
export PATH="$PATH:/usr/local/bin"
cd build
ctest --output-on-failure

- name: Running tests (Python)
run: |
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/bin
export PATH="$PATH:/usr/local/bin"
export PYTHONPATH=${PYTHONPATH}:${GITHUB_WORKSPACE}/install/libs
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GITHUB_WORKSPACE}/install/libs
cd tests
# TODO delete build dir to make sure the linking etc works correctly? (Needs to be done after running CTests)
python3.8 run_python_tests.py
python3.10 run_python_tests.py


Ubuntu-minimum-CMake:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ tests/compiled_config.json
# Most used editor files
*.vscode
*.vs
.clangd
CMakeSettings.json
29 changes: 23 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
cmake_minimum_required (VERSION 3.15.0)

if(POLICY CMP0048)
# project command manages version
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)
project(CoSimIO LANGUAGES CXX C VERSION 3.0.0)

if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()

# this has to be specified BEFORE including CTest!
# suppressions file has to be included in the options, as using "MEMORYCHECK_SUPPRESSIONS_FILE" doesn't work on all systems
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-leak-kinds=all --track-origins=yes --tool=memcheck --error-exitcode=1 --suppressions=${CMAKE_CURRENT_SOURCE_DIR}/tests/valgrind_suppressions.supp --gen-suppressions=all")
Expand Down Expand Up @@ -76,7 +85,7 @@ if(MSVC)
endif()

elseif(${CMAKE_COMPILER_IS_GNUCXX})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")

if (CO_SIM_IO_STRICT_COMPILER)
Expand All @@ -92,7 +101,7 @@ elseif(${CMAKE_COMPILER_IS_GNUCXX})
# Note: This command makes sure that this option comes pretty late on the cmdline.
link_libraries("$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,7.0>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:-lstdc++fs>")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")

if (CO_SIM_IO_STRICT_COMPILER)
Expand All @@ -101,7 +110,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")

if (CO_SIM_IO_STRICT_COMPILER)
Expand All @@ -110,7 +119,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
endif()

else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -Wall -Wpedantic")
endif()

Expand Down Expand Up @@ -138,7 +147,11 @@ include(GenerateExportHeader)
generate_export_header( co_sim_io EXPORT_MACRO_NAME CO_SIM_IO_API EXPORT_FILE_NAME
${CMAKE_CURRENT_SOURCE_DIR}/co_sim_io/includes/co_sim_io_api.hpp )

install(TARGETS co_sim_io DESTINATION bin)
install(TARGETS co_sim_io
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)

if (CO_SIM_IO_BUILD_MPI)
# optionally enable communication via MPI
Expand All @@ -157,7 +170,11 @@ if (CO_SIM_IO_BUILD_MPI)

target_link_libraries(co_sim_io_mpi co_sim_io ${MPI_LIBRARIES})

install(TARGETS co_sim_io_mpi DESTINATION bin)
install(TARGETS co_sim_io_mpi
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
endif()

target_include_directories(co_sim_io PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/co_sim_io)
Expand Down
12 changes: 10 additions & 2 deletions co_sim_io/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ set_target_properties(co_sim_io_c PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)

target_link_libraries( co_sim_io_c co_sim_io )

install(TARGETS co_sim_io_c DESTINATION bin)
install(TARGETS co_sim_io_c
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)

if (CO_SIM_IO_BUILD_MPI)
add_library (co_sim_io_c_mpi SHARED co_sim_io_c_mpi.cpp)

target_link_libraries(co_sim_io_c_mpi co_sim_io_c co_sim_io_mpi)

install(TARGETS co_sim_io_c_mpi DESTINATION bin)
install(TARGETS co_sim_io_c_mpi
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
endif()
6 changes: 5 additions & 1 deletion co_sim_io/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ add_library (co_sim_io_fortran SHARED co_sim_io.f90)

target_link_libraries( co_sim_io_fortran co_sim_io_c )

install(TARGETS co_sim_io_fortran DESTINATION bin)
install(TARGETS co_sim_io_fortran
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
50 changes: 40 additions & 10 deletions co_sim_io/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,65 @@ message("Configuring CoSimIO for Python")
# TODO make this configureable
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../external_libraries/pybind11 dummy)

# Windows has to work in mysterious ways.
# From Windows' perspective, a shared library is a runtime binary
# bot not a module, even though it's pretty much a shared library
# as well.
function(install_pybind_module target)
if (WIN32)
install(TARGETS ${target}
LIBRARY DESTINATION bin
ARCHIVE DESTINATION bin
RUNTIME DESTINATION bin)
else()
install(TARGETS ${target}
LIBRARY DESTINATION libs
ARCHIVE DESTINATION libs
RUNTIME DESTINATION bin)
endif()
endfunction()

pybind11_add_module(PyCoSimIO co_sim_io_python.cpp)

target_link_libraries( PyCoSimIO PRIVATE co_sim_io )

install(TARGETS PyCoSimIO DESTINATION bin)
file(WRITE "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/__init__.py" "from PyCoSimIO import *\nfrom PyCoSimIO import __version__\n")
if (WIN32)
set(CoSimIOPythonModuleRelativeDir "bin/CoSimIO")
else()
set(CoSimIOPythonModuleRelativeDir "libs/CoSimIO")
endif()
set(CoSimIOPythonModuleDir "${CMAKE_INSTALL_PREFIX}/${CoSimIOPythonModuleRelativeDir}")

install_pybind_module(PyCoSimIO)
set_target_properties(PyCoSimIO PROPERTIES INSTALL_RPATH "$ORIGIN")

set(CoSimIOInitFile "${CoSimIOPythonModuleDir}/__init__.py")
set(CoSimIOMPIInitFile "${CoSimIOPythonModuleDir}/mpi/__init__.py")
set(mpi4pyInterfaceInitFile "${CoSimIOPythonModuleDir}/mpi/mpi4pyInterface/__init__.py")

set(CoSimIOMPIInitFile "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/mpi/__init__.py")
set(mpi4pyInterfaceInitFile "${CMAKE_INSTALL_PREFIX}/bin/CoSimIO/mpi/mpi4pyInterface/__init__.py")
file(WRITE "${CoSimIOInitFile}" "from PyCoSimIO import *\nfrom PyCoSimIO import __version__\n")

# dummy init files that give proper errors in case something related to MPI was not compiled
# These files will be overwritten if the corresponding option is enabled, hence here we can write then unconditionally
file(WRITE ${CoSimIOMPIInitFile} "raise Exception('CoSimIO was compiled without MPI support! (use \"CO_SIM_IO_BUILD_MPI\" to enable it)')\n")
file(WRITE ${mpi4pyInterfaceInitFile} "raise Exception('The mpi4py interface was not compiled! (use \"CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE\" to enable it)')\n")
file(WRITE "${CoSimIOMPIInitFile}" "raise Exception('CoSimIO was compiled without MPI support! (use \"CO_SIM_IO_BUILD_MPI\" to enable it)')\n")
file(WRITE "${mpi4pyInterfaceInitFile}" "raise Exception('The mpi4py interface was not compiled! (use \"CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE\" to enable it)')\n")

if (CO_SIM_IO_BUILD_MPI)
pybind11_add_module(PyCoSimIOMPI co_sim_io_python_mpi.cpp)

target_link_libraries( PyCoSimIOMPI PRIVATE co_sim_io co_sim_io_mpi )

install(TARGETS PyCoSimIOMPI DESTINATION bin)
file(WRITE ${CoSimIOMPIInitFile} "from PyCoSimIOMPI import *\n")
install_pybind_module(PyCoSimIOMPI)
set_target_properties(PyCoSimIOMPI PROPERTIES INSTALL_RPATH "$ORIGIN")
file(WRITE "${CoSimIOMPIInitFile}" "from PyCoSimIOMPI import *\n")

OPTION ( CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE "Building the interface to mpi4py MPI communicators" OFF )
if (CO_SIM_IO_BUILD_PYTHON_MPI4PY_INTERFACE)
message("Building the interface to mpi4py MPI communicators")
pybind11_add_module(PyCoSimIOMPI_mpi4pyInterface mpi4py_interface.cpp)
target_link_libraries( PyCoSimIOMPI_mpi4pyInterface PRIVATE ${MPI_LIBRARIES} )
install(TARGETS PyCoSimIOMPI_mpi4pyInterface DESTINATION bin)
file(WRITE ${mpi4pyInterfaceInitFile} "from PyCoSimIOMPI_mpi4pyInterface import *\n")
install_pybind_module(PyCoSimIOMPI_mpi4pyInterface)
set_target_properties(PyCoSimIOMPI_mpi4pyInterface PROPERTIES INSTALL_RPATH "$ORIGIN")
file(WRITE "${mpi4pyInterfaceInitFile}" "from PyCoSimIOMPI_mpi4pyInterface import *\n")
endif()
endif()
2 changes: 1 addition & 1 deletion co_sim_io/python/co_sim_io_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <pybind11/numpy.h>

// must be done before CoSimIO includes
PYBIND11_DECLARE_HOLDER_TYPE(T, CoSimIO::intrusive_ptr<T>)
PYBIND11_DECLARE_HOLDER_TYPE(T, CoSimIO::intrusive_ptr<T>, false)

// CoSimIO includes
#include "co_sim_io.hpp"
Expand Down
2 changes: 1 addition & 1 deletion co_sim_io/python/connection_status_to_python.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace CoSimIO {

void AddCoSimIOConnectionStatusToPython(pybind11::module& m)
void AddCoSimIOConnectionStatusToPython(pybind11::module_& m)
{
namespace py = pybind11;

Expand Down
2 changes: 1 addition & 1 deletion co_sim_io/python/info_to_python.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void AddGetSetInterface(pybind11::class_<CoSimIO::Info>& PythonInfo, const std::

namespace CoSimIO {

void AddCoSimIOInfoToPython(pybind11::module& m)
void AddCoSimIOInfoToPython(pybind11::module_& m)
{
namespace py = pybind11;

Expand Down
Loading
Loading