Skip to content

Commit

Permalink
python: rewrite Python high level API in python
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed Dec 15, 2023
1 parent d650742 commit f6def92
Show file tree
Hide file tree
Showing 64 changed files with 2,508 additions and 1,942 deletions.
File renamed without changes.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ docs/pyvenv.cfg
# Visual Studio
.vs/
CMakeSettings.json

# Python wheels stuff

*.egg-info/
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ add_subdirectory(source)
#------------------------------------------------------------------------------#
add_subdirectory(bindings)

#------------------------------------------------------------------------------#
# Language Libraries
#------------------------------------------------------------------------------#
if(ADIOS2_HAVE_Python)
add_subdirectory(python)
endif()

#------------------------------------------------------------------------------#
# Plugins
#------------------------------------------------------------------------------#
Expand All @@ -341,6 +348,7 @@ if(ADIOS2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()


#------------------------------------------------------------------------------#
# Testing
#------------------------------------------------------------------------------#
Expand Down
42 changes: 19 additions & 23 deletions bindings/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ Python_add_library(adios2_py MODULE
py11Engine.cpp
py11Operator.cpp
py11Query.cpp
py11File.cpp py11File.tcc
py11glue.cpp
)
target_compile_definitions(adios2_py PRIVATE "ADIOS2_PYTHON_MODULE_NAME=adios2${ADIOS2_LIBRARY_SUFFIX}")
target_compile_definitions(adios2_py PRIVATE "ADIOS2_PYTHON_MODULE_NAME=adios2_bindings${ADIOS2_LIBRARY_SUFFIX}")
if(ADIOS2_HAVE_MPI)
target_sources(adios2_py PRIVATE
py11ADIOSMPI.cpp
py11FileMPI.cpp
py11IOMPI.cpp
)
set(maybe_adios2_cxx11_mpi adios2_cxx11_mpi)
Expand All @@ -29,44 +27,42 @@ target_link_libraries(adios2_py PRIVATE
${maybe_adios2_cxx11_mpi} adios2_cxx11
${maybe_adios2_core_mpi} adios2_core
adios2::thirdparty::pybind11
${maybe_mpi4py} Python::NumPy
${maybe_mpi4py}
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in
${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/__init__.py
${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings/__init__.py
@ONLY
)

set_target_properties(adios2_py PROPERTIES
CXX_VISIBILITY_PRESET hidden
OUTPUT_NAME adios2${ADIOS2_LIBRARY_SUFFIX}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
OUTPUT_NAME adios2_bindings${ADIOS2_LIBRARY_SUFFIX}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings
PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings
COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings
)

string(REGEX REPLACE "[^/]+" ".." relative_base "${CMAKE_INSTALL_PYTHONDIR}/adios2")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (NOT ADIOS2_USE_PIP)
set_target_properties(adios2_py PROPERTIES
INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}"
)
endif()
endif()

set(install_location ${CMAKE_INSTALL_PYTHONDIR})
if (ADIOS2_USE_PIP)
set(install_location ${CMAKE_INSTALL_LIBDIR})
endif()

string(REGEX REPLACE "[^/]+" ".." relative_base "${install_location}/adios2/bindings")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set_property(TARGET adios2_py APPEND PROPERTY
INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}"
)
endif()

install(TARGETS adios2_py
DESTINATION ${install_location}
DESTINATION ${install_location}/adios2/bindings
COMPONENT adios2_python-python
)
install(FILES ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/__init__.py
DESTINATION ${install_location}
install(FILES ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/bindings/__init__.py
DESTINATION ${install_location}/adios2/bindings
COMPONENT adios2_python-python
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test
Expand Down
2 changes: 1 addition & 1 deletion bindings/Python/__init__.py.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .adios2@ADIOS2_LIBRARY_SUFFIX@ import *
from .adios2_bindings@ADIOS2_LIBRARY_SUFFIX@ import *

__version__ = "@ADIOS2_VERSION@"
Loading

0 comments on commit f6def92

Please sign in to comment.