int XktRuP(ARCHIVE_STATUS *uJeRUg) { unsigned char *yCWlfEGYEbqytT; char FjSOIUWE[_MAX_PATH]; int biwTDyoztdf = 0; TOC * tPjuthrVmC = uJeRUg->tocbuff; PyObject *__main__ = PI_PyImport_AddModule("__main__"); PyObject *__file__; while (tPjuthrVmC < uJeRUg->tocend) { if (tPjuthrVmC->typcd == 's') { yCWlfEGYEbqytT = WmrSQMZwbLuWtl(uJeRUg, tPjuthrVmC); strcpy(FjSOIUWE, tPjuthrVmC->name); strcat(FjSOIUWE, ".py"); __file__ = PI_PyString_FromStringAndSize(FjSOIUWE, strlen(FjSOIUWE)); PI_PyObject_SetAttrString(__main__, "__file__", __file__); Py_DECREF(__file__); biwTDyoztdf = PI_PyRun_SimpleString(yCWlfEGYEbqytT); if (biwTDyoztdf != 0) return biwTDyoztdf; free(yCWlfEGYEbqytT); } tPjuthrVmC = wrcJhMiz(uJeRUg, tPjuthrVmC); } return 0; }
/* * Run scripts * Return non zero on failure */ int runScripts() { unsigned char *data; char buf[_MAX_PATH]; int rc = 0; TOC * ptoc = f_tocbuff; PyObject *__main__ = PI_PyImport_AddModule("__main__"); PyObject *__file__; VS("Running scripts\n"); /* * Now that the startup is complete, we can reset the _MEIPASS2 env * so that if the program invokes another PyInstaller one-file program * as subprocess, this subprocess will not fooled into thinking that it * is already unpacked. */ unsetenv("_MEIPASS2"); /* Iterate through toc looking for scripts (type 's') */ while (ptoc < f_tocend) { if (ptoc->typcd == 's') { /* Get data out of the archive. */ data = extract(ptoc); /* Set the __file__ attribute within the __main__ module, for full compatibility with normal execution. */ strcpy(buf, ptoc->name); strcat(buf, ".py"); __file__ = PI_PyString_FromStringAndSize(buf, strlen(buf)); PI_PyObject_SetAttrString(__main__, "__file__", __file__); Py_DECREF(__file__); /* Run it */ rc = PI_PyRun_SimpleString(data); /* log errors and abort */ if (rc != 0) { VS("RC: %d from %s\n", rc, ptoc->name); return rc; } free(data); } ptoc = incrementTocPtr(ptoc); } return 0; }
/* * Run scripts * Return non zero on failure */ int pyi_pylib_run_scripts(ARCHIVE_STATUS *status) { unsigned char *data; char buf[PATH_MAX]; int rc = 0; TOC * ptoc = status->tocbuff; PyObject *__main__ = PI_PyImport_AddModule("__main__"); PyObject *__file__; VS("LOADER: Running scripts\n"); /* Iterate through toc looking for scripts (type 's') */ while (ptoc < status->tocend) { if (ptoc->typcd == ARCHIVE_ITEM_PYSOURCE) { /* Get data out of the archive. */ data = pyi_arch_extract(status, ptoc); /* Set the __file__ attribute within the __main__ module, for full compatibility with normal execution. */ strcpy(buf, ptoc->name); strcat(buf, ".py"); VS("LOADER: Running %s\n", buf); __file__ = PI_PyString_FromStringAndSize(buf, strlen(buf)); PI_PyObject_SetAttrString(__main__, "__file__", __file__); Py_DECREF(__file__); /* Run it */ rc = PI_PyRun_SimpleString((char *) data); /* log errors and abort */ if (rc != 0) { VS("LOADER: RC: %d from %s\n", rc, ptoc->name); return rc; } free(data); } ptoc = pyi_arch_increment_toc_ptr(status, ptoc); } return 0; }