Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120436159
python.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jul 4, 09:07
Size
1 KB
Mime Type
text/x-c++
Expires
Sun, Jul 6, 09:07 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27177281
Attached To
rLIBMULTISCALE LibMultiScale
python.cc
View Options
#include "lm_common.hh"
#include "lm_python_bindings.hh"
#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
namespace py = pybind11;
using namespace libmultiscale;
std::vector<std::string> fake_argv;
std::vector<char *> c_argv;
void loadModules() {
// auto sys = py::module::import("sys");
// auto argv = sys.attr("argv");
// fake_argv = py::cast<std::vector<std::string>>(argv);
// std::cout << "AAAA " << fake_argv.size() << std::endl;
// for (auto &&v : fake_argv) {
// std::cout << "AAAA " << &v[0] << std::endl;
// c_argv.push_back(&v[0]);
// }
// loadModules(c_argv.size(), c_argv.data());
loadModules(0, nullptr);
create_seg_fault = false;
}
extern std::string lm_release_info;
template <typename T2, typename T>
void ModuleProperty(py::module &m, const char *n, T &var) {
// setting a property
// import the builtins and get the "property" python class
auto property = py::module::import("builtins").attr("property");
m.attr(n) = property(py::cpp_function([&]() { return var; }),
py::cpp_function([&](T2 &a) { var = a; }));
}
PYBIND11_MODULE(pylibmultiscale, m) {
m.doc() = "LibMultiScale python module";
ModuleProperty<int>(m, "current_step", current_step);
ModuleProperty<int>(m, "lm_my_proc_id", lm_my_proc_id);
ModuleProperty<IntegrationSchemeStage>(m, "current_stage", current_stage);
m.def("loadModules", &::loadModules,
"Load all the module dependencies of libmultiscale");
m.def("closeModules", &closeModules,
"close all the module dependencies of libmultiscale");
m.attr("release_info") = py::cast(lm_release_info);
makeBindings(m);
}
Event Timeline
Log In to Comment