2020#include " shambindings/pybindings.hpp"
2121#include " shambindings/start_python.hpp"
2222#include < pybind11/embed.h>
23+ #include < pybind11/stl.h>
2324#include < cstdlib>
2425#include < optional>
2526#include < string>
@@ -109,10 +110,16 @@ namespace shambindings {
109110 py::exec (modify_path);
110111 }
111112
112- void start_ipython (bool do_print) {
113+ void set_sys_argv (int argc, char *argv[]) {
114+ std::vector<std::string> cpp_argv (argv, argv + argc);
115+ py::module_::import (" sys" ).attr (" argv" ) = py::cast (cpp_argv);
116+ }
117+
118+ void start_ipython (bool do_print, int argc, char *argv[]) {
113119
114120 py::scoped_interpreter guard{};
115121 modify_py_sys_path (do_print);
122+ set_sys_argv (argc, argv);
116123
117124 if (do_print) {
118125 shambase::println (" --------------------------------------------" );
@@ -127,9 +134,10 @@ namespace shambindings {
127134 }
128135 }
129136
130- void run_py_file (std::string file_path, bool do_print) {
137+ void run_py_file (std::string file_path, bool do_print, int argc, char *argv[] ) {
131138 py::scoped_interpreter guard{};
132139 modify_py_sys_path (do_print);
140+ set_sys_argv (argc, argv);
133141
134142 if (do_print) {
135143 shambase::println (" -----------------------------------" );
0 commit comments