Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'pip install adios2' #3949

Closed
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ set(ADIOS2_EXECUTABLE_SUFFIX "${ADIOS2_LIBRARY_SUFFIX}" CACHE STRING
"Suffix to append to executable names")
mark_as_advanced(ADIOS2_LIBRARY_SUFFIX ADIOS2_EXECUTABLE_SUFFIX)

# Advanced option to tell CMake the build is on behalf of pip
set(ADIOS2_PIP_INSTALL OFF CACHE BOOL "Turn on for pip install")
mark_as_advanced(ADIOS2_PIP_INSTALL)

# Use meta-compile features if available, otherwise use specific language
# features
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang|MSVC)$")
Expand Down Expand Up @@ -371,8 +375,8 @@ endif()
message("")
message("ADIOS2 build configuration:")
message(" ADIOS Version: ${ADIOS2_VERSION}")
message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} "
"${CMAKE_CXX_COMPILER_WRAPPER}")
message(" ${CMAKE_CXX_COMPILER}")
message("")
Expand Down
11 changes: 9 additions & 2 deletions bindings/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ set_target_properties(adios2_py PROPERTIES
COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
)

string(REGEX REPLACE "[^/]+" ".." relative_base "${CMAKE_INSTALL_PYTHONDIR}/adios2")

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (ADIOS2_PIP_INSTALL)
set_target_properties(adios2_py PROPERTIES
INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}"
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicentebolea This is the hack I was referring to in chat yesterday. It's obviously not the right answer, I just added it to prove to myself that this INSTALL_RPATH was the problem with my local pip install ..

)
else()
string(REGEX REPLACE "[^/]+" ".." relative_base "${CMAKE_INSTALL_PYTHONDIR}/adios2")
set_target_properties(adios2_py PROPERTIES
INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}"
)
endif()
endif()

install(TARGETS adios2_py
Expand Down
36 changes: 24 additions & 12 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ endfunction()
# Extract the common prefix from a collection of variables
function(lists_get_prefix listVars outVar)
foreach(l IN LISTS listVars)
message(" l: ${l}")
foreach(d IN LISTS ${l})
message(" d: ${d}")
if(NOT prefix)
set(prefix "${d}")
continue()
Expand All @@ -64,6 +66,7 @@ function(lists_get_prefix listVars outVar)
endif()
endforeach()
endforeach()
message("setting ${outVar} = ${prefix} in the PARENT_SCOPE")
set(${outVar} "${prefix}" PARENT_SCOPE)
endfunction()

Expand Down Expand Up @@ -423,21 +426,30 @@ endif()

if(Python_Interpreter_FOUND)
# Setup output directories
if(Python_Development_FOUND)
lists_get_prefix("Python_INCLUDE_DIRS;Python_LIBRARIES;Python_SITEARCH" _Python_DEVPREFIX)
if (ADIOS2_PIP_INSTALL)
# do it the pip way
set(CMAKE_INSTALL_PYTHONDIR ${Python_SITEARCH})
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${Python_SITEARCH}
)
else()
lists_get_prefix("Python_EXECUTABLE;Python_SITEARCH" _Python_DEVPREFIX)
if(Python_Development_FOUND)
lists_get_prefix("Python_INCLUDE_DIRS;Python_LIBRARIES;Python_SITEARCH" _Python_DEVPREFIX)
else()
lists_get_prefix("Python_EXECUTABLE;Python_SITEARCH" _Python_DEVPREFIX)
endif()
message("This is borked! _Python_DEVPREFIX = ${_Python_DEVPREFIX}, Python_SITEARCH = ${Python_SITEARCH}")
string_strip_prefix(
"${_Python_DEVPREFIX}" "${Python_SITEARCH}" CMAKE_INSTALL_PYTHONDIR_DEFAULT
)
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR_DEFAULT}"
CACHE PATH "Install directory for python modules"
)
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
)
endif()
string_strip_prefix(
"${_Python_DEVPREFIX}" "${Python_SITEARCH}" CMAKE_INSTALL_PYTHONDIR_DEFAULT
)
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR_DEFAULT}"
CACHE PATH "Install directory for python modules"
)
mark_as_advanced(CMAKE_INSTALL_PYTHONDIR)
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
)
endif()

# Sst
Expand Down
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["scikit-build-core", "numpy"]
build-backend = "scikit_build_core.build"

[project]
name = "adios2_scottwittenburg"
version = "2.9.2"
authors = [
{ name="Chuck Atkins", email="[email protected]" },
{ name="Greg S. Eisenhauer", email="[email protected]" },
{ name="William F. Godoy", email="[email protected]" },
{ name="Junmin Gu", email="[email protected]" },
{ name="Norbert Podhorszki", email="[email protected]" },
{ name="Ruonan (Jason) Wang", email="[email protected]" },
]
description = "The Adaptable Input Output System version 2"
readme = "ReadMe.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: C++",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]

[project.urls]
Homepage = "https://github.com/ornladios/adios2"
Issues = "https://github.com/ornladios/adios2/issues"

[tool.scikit-build]
wheel.packages = ["adios2"]
build-dir = "/data/scott/Documents/adios2/pip_build"

[tool.scikit-build.cmake.define]
ADIOS2_USE_Python = "ON"
ADIOS2_USE_Fortran = "OFF"
ADIOS2_USE_MPI = "OFF"
ADIOS2_USE_HDF5 = "OFF"
ADIOS2_USE_HDF5_VOL = "OFF"
ADIOS2_USE_BZip2 = "OFF"
ADIOS2_USE_Blosc = "OFF"
ADIOS2_USE_DataMan = "OFF"
ADIOS2_USE_SZ = "OFF"
ADIOS2_USE_ZeroMQ = "OFF"
ADIOS2_USE_ZFP = "OFF"
ADIOS2_PIP_INSTALL = "ON"
Loading