#include #include //#include #include #include int main(int argc, char** argv) { printf("cli test application\n"); wchar_t *program = Py_DecodeLocale(argv[0], NULL); if (program == NULL) { fprintf(stderr, "Fatal error: cannot decode argv[0]\n"); exit(1); } // inform the interpreter about paths to run-time libraries Py_SetProgramName(program); /* optional but recommended */ // Initialize the python interpreter Py_Initialize(); PyRun_SimpleString("print('Python interpreter ready')\n"); const char* prompt = "poi> "; while(true) { char *cmd = linenoise(prompt); if(cmd == nullptr || *cmd == '\0') { printf("break\n"); free(cmd); break; } //printf("echo(%i):'%s'\n", strlen(cmd), cmd); PyRun_SimpleString(cmd); free(cmd); } // finalize the interpreter if (Py_FinalizeEx() < 0) { exit(120); } // PyMem_RawFree(program); return 0; }