Skip to content

Commit

Permalink
bootloader: add _MEIPASS/lib-dynload to the initial sys.path
Browse files Browse the repository at this point in the history
  • Loading branch information
rokm committed Apr 1, 2021
1 parent e6edae5 commit 5730a4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bootloader/src/pyi_pythonlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pyi_pylib_start_python(ARCHIVE_STATUS *status)
* its contents nor free its memory.
*
* NOTE: Statics are zero-initialized. */
static char pypath[2 * PATH_MAX + 14];
static char pypath[3 * PATH_MAX + 32];

/* Wide string forms of the above, for Python 3. */
static wchar_t pypath_w[PATH_MAX + 1];
Expand All @@ -419,9 +419,13 @@ pyi_pylib_start_python(ARCHIVE_STATUS *status)
PI_Py_SetPythonHome(pyhome_w);

/* Set sys.path */
/* sys.path = [base_library, mainpath] */
if (snprintf(pypath, sizeof pypath, "%s%cbase_library.zip%c%s",
status->mainpath, PYI_SEP, PYI_PATHSEP, status->mainpath)
/* sys.path = [mainpath/base_library.zip, mainpath/lib-dynload, mainpath] */
if (snprintf(pypath, sizeof pypath, "%s%c%s" "%c" "%s%c%s" "%c" "%s",
status->mainpath, PYI_SEP, "base_library.zip",
PYI_PATHSEP,
status->mainpath, PYI_SEP, "lib-dynload",
PYI_PATHSEP,
status->mainpath)
>= sizeof pypath) {
// This should never happen, since mainpath is < PATH_MAX and pypath is
// huge enough
Expand Down

0 comments on commit 5730a4e

Please sign in to comment.