forked from hoffstadt/DearPyGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_linux.cpp
More file actions
89 lines (76 loc) · 2.14 KB
/
main_linux.cpp
File metadata and controls
89 lines (76 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "dearpygui.h"
#include "mvViewport.h"
#include <fstream>
#include <string>
#include <sstream>
void runTest(std::string test)
{
auto ss = std::ostringstream{};
std::ifstream input_file("../../testing/" + test + ".py");
#ifndef MV_TESTS_ONLY
ss << "should_exit = False\n";
#else
ss << "should_exit = True\n";
#endif
ss << input_file.rdbuf();
PyRun_SimpleString(ss.str().c_str());
}
int main(int argc, char* argv[])
{
GenerateStubFile("../../dearpygui");
GenerateDearPyGuiFile("../../dearpygui");
GenerateDearPyGuiFileRTD("../../dearpygui");
// initialize python
// add our custom module
PyImport_AppendInittab("_dearpygui", &PyInit__dearpygui);
// set path and start the interpreter
#if defined(__APPLE__)
wchar_t *deco = Py_DecodeLocale(
PYTHON_LIBS_PATH":"
PYTHON_LIBS_PATH"/lib-dynload:"
PYTHON_LIBS_PATH"/site-packages:"
"../..:"
"../../thirdparty/DearPyGui_Ext:"
"../../sandbox",
nullptr);
#else
wchar_t *deco = Py_DecodeLocale(
"../../thirdparty/DearPyGui_Ext/:../../thirdparty/cpython/build/debug/build/lib.linux-x86_64-3.9-pydebug/:../"
"../thirdparty/cpython/Lib/:../..:../../sandbox",
nullptr);
#endif
Py_SetPath(deco);
Py_NoSiteFlag = 1; // this must be set to 1
Py_DontWriteBytecodeFlag = 1;
//_PyEval_SetSwitchInterval()
Py_Initialize();
if (!Py_IsInitialized())
{
printf("Error initializing Python interpreter\n");
return 1;
}
// This one requires Python interpreter because internally it uses temporary PyObjects
// (hackyish but that's the best we can do for now). That's why we call it here rather
// than together with all other GenerateXYZ functions.
GenerateTypeInfoModule("../../dearpygui");
PyObject* mmarvel = PyImport_ImportModule("_dearpygui");
// tests
runTest("simple_tests");
#ifndef MV_TESTS_ONLY
// sandbox
{
auto ss = std::ostringstream{};
std::ifstream input_file("../../sandbox/sandbox.py");
ss << input_file.rdbuf();
PyRun_SimpleString(ss.str().c_str());
}
#endif
// check if error occurred
if (!PyErr_Occurred())
Py_XDECREF(mmarvel);
else
PyErr_Print();
return 0;
}