Skip to content

Commit

Permalink
Do not create an opm_embedded library as embedded anymore, this is au…
Browse files Browse the repository at this point in the history
…tomatically taken from the globally installed python
  • Loading branch information
lisajulia committed Apr 26, 2024
1 parent 37ff6ef commit f2c0ab7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 95 deletions.
27 changes: 19 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,27 @@ if (OPM_ENABLE_PYTHON)
# extra cmake switch, OPM_INSTALL_PYTHON. If you prefer you can still invoke
# setup.py install manually - optionally with the generated script
# setup-install.sh - and completely bypass cmake in the installation phase.
if (OPM_INSTALL_PYTHON)
# If OPM_ENABLE_EMBEDDED_PYTHON is turned on, then we install the
# opm_embedded module, to make it available for e.g. opm-simulators
if (OPM_INSTALL_PYTHON OR OPM_ENABLE_EMBEDDED_PYTHON)
include(PyInstallPrefix)
install(TARGETS opmcommon_python DESTINATION ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}/opm)
install(
CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE}
python/install.py
${PROJECT_BINARY_DIR}/python/opm
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")

if (OPM_INSTALL_PYTHON)
install(
CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE}
python/install.py
${PROJECT_BINARY_DIR}/python/opm
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
endif()
if (OPM_ENABLE_EMBEDDED_PYTHON)
install(
CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE}
python/install.py
${PROJECT_BINARY_DIR}/python/opm_embedded
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
endif()
## Need to install this Python script such that it can be used by opm-simulators when building against an installed
## opm-common
install( PROGRAMS "python/install.py" DESTINATION "${OPM_PYTHON_COMMON_DIR}" )
Expand Down
69 changes: 0 additions & 69 deletions opm/input/eclipse/Python/EmbedModule.hpp

This file was deleted.

13 changes: 0 additions & 13 deletions opm/input/eclipse/Python/PythonInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,10 @@

#include "python/cxx/export.hpp"
#include "PythonInterp.hpp"
#include "EmbedModule.hpp"

namespace py = pybind11;
namespace Opm {


/*
OPM_EMBEDDED_MODULE create a Python of all the Python/C++ classes which are
generated in the python::common::export_all_opm_embedded() function in the wrapping code.
The same module is created as a Pybind 11 module in export.cpp
*/

OPM_EMBEDDED_MODULE(opm_embedded, module) {
python::common::export_all_opm_embedded(module);
}


bool PythonInterp::exec(const std::string& python_code, py::module& context) {
py::bool_ def_result = false;
context.attr("result") = &def_result;
Expand Down
5 changes: 1 addition & 4 deletions python/cxx/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ void python::common::export_all(py::module& module) {

PYBIND11_MODULE(opmcommon_python, module) {
python::common::export_all(module);
}

void python::common::export_all_opm_embedded(py::module& module) {
python::common::export_all(module);
// These attributes are placeholders, they get set to the actual EclipseState, Schedule and SummaryState in PyRunModule.cpp
module.attr("current_ecl_state") = std::make_shared<EclipseState>();
module.attr("current_summary_state") = std::make_shared<SummaryState>();
module.attr("current_schedule") = std::make_shared<Schedule>();
module.attr("current_report_step") = 0;
module.doc() = R"pbdoc(This is the opm_embedded module for embedding python code in PYACTION.)pbdoc";
}
1 change: 0 additions & 1 deletion python/cxx/export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const py::return_value_policy move = py::return_value_policy::move;

namespace python::common {
void export_all(py::module& module);
void export_all_opm_embedded(py::module& module);
void export_UnitSystem(py::module& module);
void export_Connection(py::module& module);
void export_Deck(py::module& module);
Expand Down

0 comments on commit f2c0ab7

Please sign in to comment.