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 Mar 5, 2021
1 parent 488234c commit 4a628b2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bootloader/src/pyi_pythonlib.c
Expand Up @@ -389,7 +389,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 @@ -416,9 +416,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 4a628b2

Please sign in to comment.