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

Fix pvpython support, specifically on mbot this is needed for the CLI #5906

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions cmake/FindParaView.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ if (PVPYTHON_EXEC)
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
string(REPLACE "\n" ";" _OUTPUT "${_OUTPUT}")
list(LENGTH _OUTPUT _OUTPUT_LENGTH)
if (_OUTPUT_LENGTH EQUAL 1)
# '--print' is not supported, just get the version
list(GET _OUTPUT 0 PARAVIEW_VERSION)
elseif(_OUTPUT_LENGTH EQUAL 2)
# '--print' is supported, get the version and environment variables
list(GET _OUTPUT 0 PARAVIEW_PYTHON_ENV_VARS)
list(GET _OUTPUT 1 PARAVIEW_VERSION)
endif()
foreach(_ENTRY ${_OUTPUT})
# Extract the ParaView version from the output
string(FIND "${_ENTRY}" "paraview version " _FOUND)
if(NOT ${_FOUND} EQUAL -1)
set(PARAVIEW_VERSION ${_ENTRY})
endif()

# On some machines ParaView needs specific environment variables set, e.g.
# on CaltechHPC we need to set LD_LIBRARY_PATH. If other env variables
# need to be set, then we need to possibly update this.
string(FIND "${_ENTRY}" "LD_LIBRARY_PATH=" _FOUND)
if(NOT ${_FOUND} EQUAL -1)
set(PARAVIEW_PYTHON_ENV_VARS ${_ENTRY})
endif()
endforeach()
string(REPLACE "paraview version " "" PARAVIEW_VERSION "${PARAVIEW_VERSION}")
endif()

Expand All @@ -44,4 +50,10 @@ if (_RESULT EQUAL 0)
PARAVIEW_PYTHON_VERSION "${PARAVIEW_PYTHON_VERSION}")
string(REPLACE "pythonpath entry: " ""
PARAVIEW_PYTHONPATH "${PARAVIEW_PYTHONPATH}")
else()
# If for whatever reason pvpython call didn't work, try another search
get_filename_component(PVPYTHON_BINDIR ${PVPYTHON_EXEC} DIRECTORY)
get_filename_component(PVPYTHON_BASEDIR ${PVPYTHON_BINDIR} DIRECTORY)
find_path(PARAVIEW_PYTHONPATH "simple.py" ${PVPYTHON_BASEDIR})
get_filename_component(PARAVIEW_PYTHONPATH ${PARAVIEW_PYTHONPATH} DIRECTORY)
endif()
2 changes: 1 addition & 1 deletion cmake/SetupParaView.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT ENABLE_PARAVIEW)
return()
endif()

find_package(ParaView)
find_package(ParaView REQUIRED)

# Help `find_python_module` find ParaView
if (PARAVIEW_PYTHONPATH)
Expand Down
Loading