pyodide/src/main.c

47 lines
1.0 KiB
C
Raw Normal View History

2018-05-23 11:23:49 +00:00
#include <Python.h>
2018-06-14 18:19:08 +00:00
#include <emscripten.h>
2018-05-23 11:23:49 +00:00
#include "hiwire.h"
#include "js2python.h"
#include "jsimport.h"
#include "jsproxy.h"
#include "pyimport.h"
#include "pyproxy.h"
#include "python2js.h"
#include "runpython.h"
2018-06-14 18:19:08 +00:00
int
main(int argc, char** argv)
{
2018-05-23 11:23:49 +00:00
hiwire_setup();
setenv("PYTHONHOME", "/", 0);
Py_InitializeEx(0);
2018-11-08 22:25:29 +00:00
// This doesn't seem to work anymore, but I'm keeping it for good measure
// anyway The effective way to turn this off is below: setting
// sys.done_write_bytecode = True
2018-11-08 20:03:30 +00:00
setenv("PYTHONDONTWRITEBYTECODE", "1", 0);
PyObject* sys = PyImport_ImportModule("sys");
if (sys == NULL) {
return 1;
}
if (PyObject_SetAttrString(sys, "dont_write_bytecode", Py_True)) {
return 1;
}
Py_DECREF(sys);
2018-06-14 18:19:08 +00:00
if (js2python_init() || JsImport_init() || JsProxy_init() ||
pyimport_init() || pyproxy_init() || python2js_init() ||
runpython_init_js() || runpython_init_py() || runpython_finalize_js()) {
2018-05-23 11:23:49 +00:00
return 1;
}
printf("Python initialization complete\n");
emscripten_exit_with_live_runtime();
return 0;
}