Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Nov 12, 2024
1 parent 8ed86c7 commit a318fad
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 94 deletions.
7 changes: 6 additions & 1 deletion python/f2py/UseF2Py.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,13 @@ macro (add_f2py_module _name)
#message(STATUS "add_f2py_module_SOURCES: ${add_f2py_module_SOURCES}")
#message(STATUS "_inc_opts: ${_inc_opts}")
if ( F2PY_BACKEND STREQUAL "meson")
if(IFORT_HAS_DEPRECATION_WARNING)
set(MESON_F2PY_FCOMPILER "ifort -diag-disable=10448")
else()
set(MESON_F2PY_FCOMPILER "${CMAKE_Fortran_COMPILER}")
endif()
add_custom_command(OUTPUT "${_name}${F2PY_SUFFIX}"
COMMAND ${CMAKE_COMMAND} -E env "FC=${CMAKE_Fortran_COMPILER}"
COMMAND ${CMAKE_COMMAND} -E env "FC=${MESON_F2PY_FCOMPILER}"
${F2PY_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py-${_name}"
${_fcompiler_opts} ${_inc_opts} ${_lib_opts} -c ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
Expand Down
35 changes: 13 additions & 22 deletions python/f2py/esma_add_f2py_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@ macro (esma_add_f2py_module name)

add_f2py_module (${name} ${ARGN})

if (NOT CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(UNIT_TEST test_${name})
add_test (
NAME ${UNIT_TEST}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
)

add_custom_command(
TARGET ${name}
COMMENT "Running Python import test on ${name}"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
)
else ()
# This code emits the warning once
get_property(prop_defined GLOBAL PROPERTY GNU_F2PY_WARNING_EMITTED DEFINED)
if (NOT prop_defined)
ecbuild_warn("There are currently issues with GNU and f2py from Conda that prevent running tests")
define_property(GLOBAL PROPERTY GNU_F2PY_WARNING_EMITTED BRIEF_DOCS "GNU-f2py" FULL_DOCS "GNU-f2py")
endif ()
endif ()
set(UNIT_TEST test_${name})
add_test (
NAME ${UNIT_TEST}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
)

add_custom_command(
TARGET ${name}
COMMENT "Running Python import test on ${name}"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python_EXECUTABLE} -c "import ${name}"
)

endmacro ()
24 changes: 9 additions & 15 deletions python/f2py/try_f2py_compile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ macro (try_f2py_compile file var)
# Once we fully move to use ifx this can be removed
if (IFORT_HAS_DEPRECATION_WARNING)
message(STATUS "Using workaround for ifort with deprecation message")
set(IFORT_IGNORE_DEPRECATION_WARNING "ifort -diag-disable=10448")
execute_process(
COMMAND cmake -E env "FC=${FC_WITH_SPACES}" ${F2PY_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY_FCOMPILER}
WORKING_DIRECTORY ${_f2py_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)
set(MESON_F2PY_FCOMPILER "ifort -diag-disable=10448")
else ()
execute_process(
COMMAND ${F2PY_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY_FCOMPILER}
WORKING_DIRECTORY ${_f2py_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)
set(MESON_F2PY_FCOMPILER "${CMAKE_Fortran_COMPILER}")
endif ()
execute_process(
COMMAND cmake -E env "FC=${MESON_F2PY_COMPILER}" ${F2PY_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY_FCOMPILER}
WORKING_DIRECTORY ${_f2py_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)

if (result EQUAL 0)
file(GLOB F2PY_TEST_OUTPUT_FILE ${_f2py_check_bindir}/*.so)
Expand Down
45 changes: 25 additions & 20 deletions python/f2py3/UseF2Py3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -265,33 +265,38 @@ macro (add_f2py3_module _name)
#message(STATUS "add_f2py3_module_SOURCES: ${add_f2py3_module_SOURCES}")
#message(STATUS "_inc_opts: ${_inc_opts}")
if ( F2PY3_BACKEND STREQUAL "meson")
if(IFORT_HAS_DEPRECATION_WARNING)
set(MESON_F2PY3_FCOMPILER "ifort -diag-disable=10448")
else()
set(MESON_F2PY3_FCOMPILER "${CMAKE_Fortran_COMPILER}")
endif()
add_custom_command(OUTPUT "${_name}${F2PY3_SUFFIX}"
COMMAND ${CMAKE_COMMAND} -E env "FC=${CMAKE_Fortran_COMPILER}"
COMMAND ${CMAKE_COMMAND} -E env "FC=${MESON_F2PY3_FCONFILER}"
${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
${_fcompiler_opts} ${_inc_opts} ${_lib_opts} -c ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
DEPENDS ${add_f2py3_module_SOURCES}
COMMENT "[F2PY3] Building Fortran to Python3 interface module ${_name}")
else ()
if ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
add_custom_command(OUTPUT "${_name}${F2PY3_SUFFIX}"
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
${_fcompiler_opts} ${_inc_opts} -c ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
DEPENDS ${add_f2py3_module_SOURCES}
COMMENT "[F2PY3] Building Fortran to Python3 interface module ${_name}")
else ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
add_custom_command(OUTPUT "${_name}${F2PY3_SUFFIX}"
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name} -h ${_name}.pyf
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
--include-paths ${_inc_paths} --overwrite-signature ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
-c "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}/${_name}.pyf"
${_fcompiler_opts} ${_inc_opts} ${_lib_opts} ${_abs_srcs} ${_lib_opts} ${_only} ${REDIRECT_TO_DEV_NULL}
DEPENDS ${add_f2py3_module_SOURCES}
COMMENT "[F2PY3] Building Fortran to Python3 interface module ${_name}")
endif ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
if ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
add_custom_command(OUTPUT "${_name}${F2PY3_SUFFIX}"
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
${_fcompiler_opts} ${_inc_opts} -c ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
DEPENDS ${add_f2py3_module_SOURCES}
COMMENT "[F2PY3] Building Fortran to Python3 interface module ${_name}")
else ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
add_custom_command(OUTPUT "${_name}${F2PY3_SUFFIX}"
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name} -h ${_name}.pyf
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
--include-paths ${_inc_paths} --overwrite-signature ${_abs_srcs} ${REDIRECT_TO_DEV_NULL}
COMMAND ${F2PY3_EXECUTABLE} ${F2PY_QUIET} -m ${_name}
--build-dir "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}"
-c "${CMAKE_CURRENT_BINARY_DIR}/f2py3-${_name}/${_name}.pyf"
${_fcompiler_opts} ${_inc_opts} ${_lib_opts} ${_abs_srcs} ${_lib_opts} ${_only} ${REDIRECT_TO_DEV_NULL}
DEPENDS ${add_f2py3_module_SOURCES}
COMMENT "[F2PY3] Building Fortran to Python3 interface module ${_name}")
endif ( "${add_f2py3_module_SOURCES}" MATCHES "^[^;]*\\.pyf;" )
endif ()


Expand Down
33 changes: 12 additions & 21 deletions python/f2py3/esma_add_f2py3_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@ macro (esma_add_f2py3_module name)

add_f2py3_module (${name} ${ARGN})

if (NOT CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(UNIT_TEST test_${name})
add_test (
NAME ${UNIT_TEST}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
)
set(UNIT_TEST test_${name})
add_test (
NAME ${UNIT_TEST}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
)

add_custom_command(
TARGET ${name}
COMMENT "Running Python3 import test on ${name}"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
)
else ()
# This code emits the warning once
get_property(prop_defined GLOBAL PROPERTY GNU_F2PY3_WARNING_EMITTED DEFINED)
if (NOT prop_defined)
ecbuild_warn("There are currently issues with GNU and f2py3 from Conda that prevent running tests")
define_property(GLOBAL PROPERTY GNU_F2PY3_WARNING_EMITTED BRIEF_DOCS "GNU-f2py3" FULL_DOCS "GNU-f2py3")
endif ()
endif ()
add_custom_command(
TARGET ${name}
COMMENT "Running Python3 import test on ${name}"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}" ${Python3_EXECUTABLE} -c "import ${name}"
)

endmacro ()
24 changes: 9 additions & 15 deletions python/f2py3/try_f2py3_compile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ macro (try_f2py3_compile file var)
# Once we fully move to use ifx this can be removed
if (IFORT_HAS_DEPRECATION_WARNING)
message(STATUS "Using workaround for ifort with deprecation message")
set(IFORT_IGNORE_DEPRECATION_WARNING "ifort -diag-disable=10448")
execute_process(
COMMAND cmake -E env "FC=${FC_WITH_SPACES}" ${F2PY3_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY3_FCOMPILER}
WORKING_DIRECTORY ${_f2py3_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)
set(MESON_F2PY3_FCOMPILER "ifort -diag-disable=10448")
else ()
execute_process(
COMMAND ${F2PY3_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY3_FCOMPILER}
WORKING_DIRECTORY ${_f2py3_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)
set(MESON_F2PY3_FCOMPILER "${CMAKE_Fortran_COMPILER}")
endif ()
execute_process(
COMMAND cmake -E env "FC=${MESON_F2PY3_COMPILER}" ${F2PY3_EXECUTABLE} -m test_ -c ${file} --fcompiler=${F2PY3_FCOMPILER}
WORKING_DIRECTORY ${_f2py3_check_bindir}
RESULT_VARIABLE result
OUTPUT_QUIET
ERROR_QUIET
)

if (result EQUAL 0)
file(GLOB F2PY3_TEST_OUTPUT_FILE ${_f2py3_check_bindir}/*.so)
Expand Down

0 comments on commit a318fad

Please sign in to comment.