Ejemplo n.º 1
0
/*
 * Once init'ed, you might want to extractBinaries()
 * If you do, what comes after is very platform specific.
 * Once you've taken care of the platform specific details,
 * or if there are no binaries to extract, you go on
 * to pyi_launch_execute(), which is the important part.
 */
int pyi_launch_execute(ARCHIVE_STATUS *status, int argc, char *argv[])
{
	int rc = 0;

	/* Load Python DLL */
    if (pyi_pylib_load(status)) {
		return -1;
    }
    else {
        /* With this flag Python cleanup will be called. */
        status->is_pylib_loaded = true;
    }

	/* Start Python. */
	if (pyi_pylib_start_python(status, argc, argv))
		return -1;

	/* Import modules from archive - bootstrap */
	if (pyi_pylib_import_modules(status))
		return -1;

	/* Install zlibs  - now all hooks in place */
	if (pyi_pylib_install_zlibs(status))
		return -1;

	/* Run scripts */
	rc = pyi_pylib_run_scripts(status);

	VS("LOADER: OK.\n");

	return rc;
}
Ejemplo n.º 2
0
/*
 * Once init'ed, you might want to extractBinaries()
 * If you do, what comes after is very platform specific.
 * Once you've taken care of the platform specific details,
 * or if there are no binaries to extract, you go on
 * to pyi_launch_execute(), which is the important part.
 */
int pyi_launch_execute(ARCHIVE_STATUS *status, int argc, char *argv[])
{
	int rc = 0;

	/* Load Python DLL */
    if (pyi_pylib_load(status)) {
		return -1;
    }
    else {
        /* With this flag Python cleanup will be called. */
        status->is_pylib_loaded = true;
    }

	/* Start Python. */
	if (pyi_pylib_start_python(status, argc, argv))
		return -1;

	/* Import modules from archive - bootstrap */
	if (pyi_pylib_import_modules(status))
		return -1;

	/* Install zlibs  - now all hooks in place */
	if (pyi_pylib_install_zlibs(status))
		return -1;

    /*
     * On Linux sys.getfilesystemencoding() returns None but should not.
     * If it's None(NULL), get the filesystem encoding by using direct
     * C calls and override it with correct value.
     */
    if (!*PI_Py_FileSystemDefaultEncoding) {
        char *saved_locale, *loc_codeset;
        saved_locale = strdup(setlocale(LC_CTYPE, NULL));
        setlocale(LC_CTYPE, "");
        loc_codeset = nl_langinfo(CODESET);
        setlocale(LC_CTYPE, saved_locale);
        free(saved_locale);
        *PI_Py_FileSystemDefaultEncoding = loc_codeset;
    }

	/* Run scripts */
	rc = pyi_pylib_run_scripts(status);

	VS("LOADER: OK.\n");

	return rc;
}