mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Remove exists check for Python and make GeneratedPythonSources depend on ResInsight
This commit is contained in:
@@ -536,17 +536,6 @@ if(RESINSIGHT_ENABLE_UNITY_BUILD)
|
|||||||
endforeach(fileToExclude)
|
endforeach(fileToExclude)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#########################################################
|
|
||||||
# Generate Script stubs and Scripting API documentation #
|
|
||||||
#########################################################
|
|
||||||
if (RESINSIGHT_ENABLE_GRPC)
|
|
||||||
add_custom_command(TARGET ResInsight POST_BUILD
|
|
||||||
BYPRODUCTS ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
|
||||||
COMMAND $<TARGET_FILE_DIR:ResInsight>/ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
|
||||||
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py"
|
|
||||||
)
|
|
||||||
endif(RESINSIGHT_ENABLE_GRPC)
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# Copy Dlls on MSVC
|
# Copy Dlls on MSVC
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -616,16 +605,18 @@ foreach (FILE_TO_COPY ${RI_DLL_FILENAMES})
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Make sure we perform the Python code generation by having a target which ResInsight depends on
|
# Generate Python code in a target that is part of ALL_BUILD and depends on ResInsight
|
||||||
if (RESINSIGHT_ENABLE_GRPC)
|
if (RESINSIGHT_ENABLE_GRPC)
|
||||||
set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE "" CACHE FILEPATH "gRPC : Path to Python 3 executable, required to build the Python client library")
|
set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE "" CACHE FILEPATH "gRPC : Path to Python 3 executable, required to build the Python client library")
|
||||||
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
add_custom_command(OUTPUT ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
||||||
add_custom_target(GeneratedPythonSources DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
|
COMMAND ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
||||||
add_dependencies(ResInsight GeneratedPythonSources)
|
DEPENDS ResInsight
|
||||||
else()
|
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py"
|
||||||
message(STATUS "Error installing python code: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
|
)
|
||||||
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
list(APPEND GRPC_GENERATED_PYTHON_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py)
|
||||||
|
add_custom_target(GeneratedPythonSources ALL DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
|
||||||
|
add_dependencies(GeneratedPythonSources ResInsight)
|
||||||
else()
|
else()
|
||||||
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install GRPC Python code.")
|
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not install GRPC Python code.")
|
||||||
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
@@ -773,7 +764,7 @@ if (RESINSIGHT_PRIVATE_INSTALL)
|
|||||||
# install gRPC Python files
|
# install gRPC Python files
|
||||||
if (RESINSIGHT_ENABLE_GRPC)
|
if (RESINSIGHT_ENABLE_GRPC)
|
||||||
message(STATUS "GRPC enabled")
|
message(STATUS "GRPC enabled")
|
||||||
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
message(STATUS "Python found")
|
message(STATUS "Python found")
|
||||||
if (RESINSIGHT_GRPC_BUNDLE_PYTHON_MODULE)
|
if (RESINSIGHT_GRPC_BUNDLE_PYTHON_MODULE)
|
||||||
message(STATUS "Bundling Python GRPC modules")
|
message(STATUS "Bundling Python GRPC modules")
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Cannot use the nice new FindPackage modules for python since that is CMake 3.12+
|
# Cannot use the nice new FindPackage modules for python since that is CMake 3.12+
|
||||||
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
if(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
message(STATUS "Using Python ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}")
|
message(STATUS "Using Python ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}")
|
||||||
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE AND EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
|
|
||||||
# Proto files
|
# Proto files
|
||||||
set(PROTO_FILES
|
set(PROTO_FILES
|
||||||
@@ -121,29 +121,25 @@ foreach(proto_file ${PROTO_FILES})
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
set(rips_proto_python "rips/generated/${proto_file}_pb2.py")
|
||||||
set(rips_proto_python "rips/generated/${proto_file}_pb2.py")
|
set(rips_grpc_python "rips/generated/${proto_file}_pb2_grpc.py")
|
||||||
set(rips_grpc_python "rips/generated/${proto_file}_pb2_grpc.py")
|
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${GRPC_PYTHON_SOURCE_PATH}/${rips_proto_python}" "${GRPC_PYTHON_SOURCE_PATH}/${rips_grpc_python}"
|
OUTPUT "${GRPC_PYTHON_SOURCE_PATH}/${rips_proto_python}" "${GRPC_PYTHON_SOURCE_PATH}/${rips_grpc_python}"
|
||||||
COMMAND ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}
|
COMMAND ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE}
|
||||||
ARGS -m grpc_tools.protoc
|
ARGS -m grpc_tools.protoc
|
||||||
-I "${rips_proto_path}"
|
-I "${rips_proto_path}"
|
||||||
--python_out "${GRPC_PYTHON_SOURCE_PATH}/rips/generated"
|
--python_out "${GRPC_PYTHON_SOURCE_PATH}/rips/generated"
|
||||||
--grpc_python_out "${GRPC_PYTHON_SOURCE_PATH}/rips/generated"
|
--grpc_python_out "${GRPC_PYTHON_SOURCE_PATH}/rips/generated"
|
||||||
"${rips_proto}"
|
"${rips_proto}"
|
||||||
DEPENDS "${rips_proto}"
|
DEPENDS "${rips_proto}"
|
||||||
COMMENT "Generating ${rips_proto_python} and ${rips_grpc_python}"
|
COMMENT "Generating ${rips_proto_python} and ${rips_grpc_python}"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
list (APPEND GRPC_PYTHON_GENERATED_SOURCES
|
list (APPEND GRPC_PYTHON_GENERATED_SOURCES
|
||||||
${rips_proto_python}
|
${rips_proto_python}
|
||||||
${rips_grpc_python}
|
${rips_grpc_python}
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
message(STATUS "Error generating Python for ${rips_proto}: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
|
|
||||||
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not generate GRPC Python code.")
|
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not generate GRPC Python code.")
|
||||||
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
@@ -161,77 +157,73 @@ foreach(proto_file ${PROTO_FILES})
|
|||||||
endforeach(proto_file)
|
endforeach(proto_file)
|
||||||
|
|
||||||
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
if (EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.py.cmake
|
||||||
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.py.cmake
|
${GRPC_PYTHON_SOURCE_PATH}/rips/generated/RiaVersionInfo.py)
|
||||||
${GRPC_PYTHON_SOURCE_PATH}/rips/generated/RiaVersionInfo.py)
|
CONFIGURE_FILE( ${GRPC_PYTHON_SOURCE_PATH}/setup.py.cmake
|
||||||
CONFIGURE_FILE( ${GRPC_PYTHON_SOURCE_PATH}/setup.py.cmake
|
${GRPC_PYTHON_SOURCE_PATH}/setup.py)
|
||||||
${GRPC_PYTHON_SOURCE_PATH}/setup.py)
|
|
||||||
|
|
||||||
list(APPEND GRPC_PYTHON_SOURCES
|
list(APPEND GRPC_PYTHON_SOURCES
|
||||||
"rips/generated/RiaVersionInfo.py"
|
"rips/generated/RiaVersionInfo.py"
|
||||||
"rips/__init__.py"
|
"rips/__init__.py"
|
||||||
"rips/case.py"
|
"rips/case.py"
|
||||||
"rips/contour_map.py"
|
"rips/contour_map.py"
|
||||||
"rips/grid.py"
|
"rips/grid.py"
|
||||||
"rips/gridcasegroup.py"
|
"rips/gridcasegroup.py"
|
||||||
"rips/project.py"
|
"rips/project.py"
|
||||||
"rips/instance.py"
|
"rips/instance.py"
|
||||||
"rips/pdmobject.py"
|
"rips/pdmobject.py"
|
||||||
"rips/plot.py"
|
"rips/plot.py"
|
||||||
"rips/simulation_well.py"
|
"rips/simulation_well.py"
|
||||||
"rips/view.py"
|
"rips/view.py"
|
||||||
"rips/wellpath.py"
|
"rips/wellpath.py"
|
||||||
"rips/well_log_plot.py"
|
"rips/well_log_plot.py"
|
||||||
"rips/well_bore_stability_plot.py"
|
"rips/well_bore_stability_plot.py"
|
||||||
"rips/PythonExamples/instance_example.py"
|
"rips/PythonExamples/instance_example.py"
|
||||||
"rips/PythonExamples/command_example.py"
|
"rips/PythonExamples/command_example.py"
|
||||||
"rips/PythonExamples/case_grid_group.py"
|
"rips/PythonExamples/case_grid_group.py"
|
||||||
"rips/PythonExamples/case_info_streaming_example.py"
|
"rips/PythonExamples/case_info_streaming_example.py"
|
||||||
"rips/PythonExamples/create_wbs_plot.py"
|
"rips/PythonExamples/create_wbs_plot.py"
|
||||||
"rips/PythonExamples/export_plots.py"
|
"rips/PythonExamples/export_plots.py"
|
||||||
"rips/PythonExamples/export_snapshots.py"
|
"rips/PythonExamples/export_snapshots.py"
|
||||||
"rips/PythonExamples/error_handling.py"
|
"rips/PythonExamples/error_handling.py"
|
||||||
"rips/PythonExamples/import_well_paths_and_logs.py"
|
"rips/PythonExamples/import_well_paths_and_logs.py"
|
||||||
"rips/PythonExamples/soil_porv_async.py"
|
"rips/PythonExamples/soil_porv_async.py"
|
||||||
"rips/PythonExamples/soil_porv_sync.py"
|
"rips/PythonExamples/soil_porv_sync.py"
|
||||||
"rips/PythonExamples/selected_cases.py"
|
"rips/PythonExamples/selected_cases.py"
|
||||||
"rips/PythonExamples/all_cases.py"
|
"rips/PythonExamples/all_cases.py"
|
||||||
"rips/PythonExamples/set_grid_properties.py"
|
"rips/PythonExamples/set_grid_properties.py"
|
||||||
"rips/PythonExamples/set_cell_result.py"
|
"rips/PythonExamples/set_cell_result.py"
|
||||||
"rips/PythonExamples/set_flow_diagnostics_result.py"
|
"rips/PythonExamples/set_flow_diagnostics_result.py"
|
||||||
"rips/PythonExamples/grid_information.py"
|
"rips/PythonExamples/grid_information.py"
|
||||||
"rips/PythonExamples/input_prop_test_sync.py"
|
"rips/PythonExamples/input_prop_test_sync.py"
|
||||||
"rips/PythonExamples/input_prop_test_async.py"
|
"rips/PythonExamples/input_prop_test_async.py"
|
||||||
"rips/PythonExamples/soil_average_async.py"
|
"rips/PythonExamples/soil_average_async.py"
|
||||||
"rips/PythonExamples/soil_average_sync.py"
|
"rips/PythonExamples/soil_average_sync.py"
|
||||||
"rips/PythonExamples/view_example.py"
|
"rips/PythonExamples/view_example.py"
|
||||||
"rips/tests/test_cases.py"
|
"rips/tests/test_cases.py"
|
||||||
"rips/tests/test_grids.py"
|
"rips/tests/test_grids.py"
|
||||||
"rips/tests/test_properties.py"
|
"rips/tests/test_properties.py"
|
||||||
"rips/tests/test_project.py"
|
"rips/tests/test_project.py"
|
||||||
"rips/tests/conftest.py"
|
"rips/tests/conftest.py"
|
||||||
"rips/tests/dataroot.py"
|
"rips/tests/dataroot.py"
|
||||||
"rips/tests/test_nnc_properties.py"
|
"rips/tests/test_nnc_properties.py"
|
||||||
"rips/tests/test_simulation_wells.py"
|
"rips/tests/test_simulation_wells.py"
|
||||||
"rips/tests/test_wells.py"
|
"rips/tests/test_wells.py"
|
||||||
"requirements.txt"
|
"requirements.txt"
|
||||||
"setup.py"
|
"setup.py"
|
||||||
"README.md"
|
"README.md"
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND GRPC_PYTHON_SOURCES ${GRPC_PYTHON_GENERATED_SOURCES})
|
list(APPEND GRPC_PYTHON_SOURCES ${GRPC_PYTHON_GENERATED_SOURCES})
|
||||||
|
|
||||||
foreach(PYTHON_SCRIPT ${GRPC_PYTHON_SOURCES})
|
foreach(PYTHON_SCRIPT ${GRPC_PYTHON_SOURCES})
|
||||||
list(APPEND GRPC_PYTHON_SOURCES_FULL_PATH "${GRPC_PYTHON_SOURCE_PATH}/${PYTHON_SCRIPT}")
|
list(APPEND GRPC_PYTHON_SOURCES_FULL_PATH "${GRPC_PYTHON_SOURCE_PATH}/${PYTHON_SCRIPT}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
source_group(TREE ${GRPC_PYTHON_SOURCE_PATH} FILES ${GRPC_PYTHON_SOURCES_FULL_PATH} PREFIX "GrpcInterface\\Python")
|
source_group(TREE ${GRPC_PYTHON_SOURCE_PATH} FILES ${GRPC_PYTHON_SOURCES_FULL_PATH} PREFIX "GrpcInterface\\Python")
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
else()
|
|
||||||
message(STATUS "Error copying GRPC Python Code to build folder: RESINSIGHT_GRPC_PYTHON_EXECUTABLE set but ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE} not found")
|
|
||||||
endif(EXISTS ${RESINSIGHT_GRPC_PYTHON_EXECUTABLE})
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not copy grpc Python code to build folder")
|
message(STATUS "RESINSIGHT_GRPC_PYTHON_EXECUTABLE not specified. Will not copy grpc Python code to build folder")
|
||||||
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
endif(RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||||
|
|||||||
Reference in New Issue
Block a user