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

Update cppyy #60

Closed
wants to merge 2 commits into from
Closed
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
48 changes: 37 additions & 11 deletions cmake/FindCppyy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Set minimal cppyy version
#
set(cppyy_version "2.4.0")
set(cppyy_version "2.4.1")
#
# Make sure Python3 is installed
#
Expand All @@ -13,34 +13,60 @@ find_package(Python3 COMPONENTS Interpreter REQUIRED)
# Check if cppyy Python package exists
#
execute_process(
COMMAND Python3::Interpreter -c "import cppyy"
RESULT_VARIABLE _fcppyy_result
COMMAND ${Python3_EXECUTABLE} -c "import cppyy"
OUTPUT_VARIABLE _fcppyy_result
)
#
# If cppyy exists, check version
#
if("${_fcppyy_result}" STREQUAL "")
set(Cppyy_FOUND TRUE)
execute_process(
COMMAND Python3::Interpreter -c "import cppyy; print(cppyy.__version__)"
RESULT_VARIABLE _fcppyy_result2
COMMAND ${Python3_EXECUTABLE} -c "import cppyy; print(cppyy.__version__),"
OUTPUT_VARIABLE _fcppyy_result2
)
else()
set(Cppyy_FOUND FALSE)
endif()
#
# Try to install cppyy Python package, if it doesn't exist or is incorrect version
#
if(NOT "${_fcppyy_result}" STREQUAL "" OR NOT "${_fcppyy_result2}" STREQUAL "${cppyy_version}")
if("${_fcppyy_result}" STREQUAL "" OR NOT "${_fcppyy_result2}" VERSION_EQUAL "${cppyy_version}")
if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX})
set(_pip_args)
set(_pip_args)
else()
set(_pip_args "--user")
set(_pip_args "--user")
endif()
set(_pypkg_name "cppyy==${cppyy_version}")
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install ${_pypkg_name} ${_pip_args})
#
# Check again if cppyy Python works
#
execute_process(COMMAND Python3::Interpreter -c "import cppyy" RESULT_VARIABLE _fcppyy_result)
if(NOT "${_fcppyy_result}" STREQUAL "")
set(Cppyy_FOUND FALSE)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import cppyy" OUTPUT_VARIABLE _fcppyy_result)
if("${_fcppyy_result}" STREQUAL "")
set(Cppyy_FOUND TRUE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import cppyy; print(cppyy.__version__),"
OUTPUT_VARIABLE _fcppyy_result2
)
else()
set(Cppyy_FOUND FALSE)
endif()
#
# Check the version again
#
if("${_fcppyy_result2}" VERSION_EQUAL "${cppyy_version}")
set(Cppyy_FOUND TRUE)
else()
set(Cppyy_FOUND FALSE)
endif()
else()
set(Cppyy_FOUND TRUE)
endif()

if(NOT Cppyy_FOUND)
message("Python3: ${Python3_EXECUTABLE}")
message("import output: ${_fcppyy_result}")
message("version output: ${_fcppyy_result2}")
message(FATAL_ERROR "CMake could not install cppyy, try installing cppyy ${cppyy_version} manually.")
endif()
1 change: 0 additions & 1 deletion cmake/nwx_python_mods.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function(cppyy_make_python_package)
#---------------------------------------------------------------------------
get_true_target_property(include_dirs ${install_data_PACKAGE} INTERFACE_INCLUDE_DIRECTORIES)
list(APPEND include_dirs ${MPI_CXX_HEADER_DIR})
list(APPEND include_dirs ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
list(REMOVE_DUPLICATES include_dirs)
#---------------------------------------------------------------------------
#--------------------------Get headers to include---------------------------
Expand Down