Tell _frozen_importlib to consider bytecode first (#248)

This commit is contained in:
Gautham 2021-08-18 10:37:27 +05:30 committed by GitHub
parent c70422586a
commit ace523c79b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2896 additions and 2887 deletions

View file

@ -1364,7 +1364,7 @@ def _get_supported_file_loaders():
extensions = ExtensionFileLoader, _imp.extension_suffixes() extensions = ExtensionFileLoader, _imp.extension_suffixes()
source = SourceFileLoader, SOURCE_SUFFIXES source = SourceFileLoader, SOURCE_SUFFIXES
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
return [extensions, source, bytecode] return [extensions, bytecode, source]
def _setup(_bootstrap_module): def _setup(_bootstrap_module):

View file

@ -123,6 +123,9 @@ def removeduppaths():
# Filter out duplicate paths (on case-insensitive file systems also # Filter out duplicate paths (on case-insensitive file systems also
# if they only differ in case); turn relative paths into absolute # if they only differ in case); turn relative paths into absolute
# paths. # paths.
if dir.startswith("zip!"): # don't absolutize, look within the APE!
L.append(dir)
continue
dir, dircase = makepath(dir) dir, dircase = makepath(dir)
if not dircase in known_paths: if not dircase in known_paths:
L.append(dir) L.append(dir)

View file

@ -120,7 +120,8 @@ wchar_t *Py_GetProgramName(void);
static wchar_t prefix[MAXPATHLEN+1]; static wchar_t prefix[MAXPATHLEN+1];
static wchar_t exec_prefix[MAXPATHLEN+1]; static wchar_t exec_prefix[MAXPATHLEN+1];
static wchar_t progpath[MAXPATHLEN+1]; static wchar_t progpath[MAXPATHLEN+1];
static wchar_t *module_search_path = NULL; static wchar_t limited_search_path[] = L"zip!.python";
static wchar_t *module_search_path = limited_search_path;
/* Get file status. Encode the path to the locale encoding. */ /* Get file status. Encode the path to the locale encoding. */
@ -466,7 +467,6 @@ search_for_exec_prefix(wchar_t *argv0_path, wchar_t *home,
static void static void
calculate_path(void) calculate_path(void)
{ {
#if 0
static wchar_t delimiter[2] = {DELIM, '\0'}; static wchar_t delimiter[2] = {DELIM, '\0'};
static wchar_t separator[2] = {SEP, '\0'}; static wchar_t separator[2] = {SEP, '\0'};
/* ignore PYTHONPATH/PYTHONHOME for now */ /* ignore PYTHONPATH/PYTHONHOME for now */
@ -608,10 +608,6 @@ calculate_path(void)
/* And publish the results */ /* And publish the results */
module_search_path = buf; module_search_path = buf;
// printf("%ls\n", buf); // printf("%ls\n", buf);
#else
module_search_path = L"zip!.python/";
/* module_search_path = L"third_party/python/Lib/"; */
#endif
} }
/* External interface */ /* External interface */

View file

@ -8,7 +8,7 @@
/* /*
* Auto-generated by * Auto-generated by
* m/third_party/python/freeze.com \ * o/third_party/python/freeze.com \
* third_party/python/Lib/importlib/_bootstrap.py \ * third_party/python/Lib/importlib/_bootstrap.py \
* third_party/python/Python/importlib.inc * third_party/python/Python/importlib.inc
*/ */

View file

@ -8,7 +8,7 @@
/* /*
* Auto-generated by * Auto-generated by
* m/third_party/python/freeze.com \ * o/third_party/python/freeze.com \
* third_party/python/Lib/importlib/_bootstrap_external.py \ * third_party/python/Lib/importlib/_bootstrap_external.py \
* third_party/python/Python/importlib_external.inc * third_party/python/Python/importlib_external.inc
*/ */
@ -2289,7 +2289,7 @@ const unsigned char _Py_M__importlib_external[] = {
0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67, 0,0,0,0,0,0,0,3,0,0,0,3,0,0,0,67,
0,0,0,115,38,0,0,0,116,0,116,1,106,2,131,0, 0,0,0,115,38,0,0,0,116,0,116,1,106,2,131,0,
102,2,125,0,116,3,116,4,102,2,125,1,116,5,116,6, 102,2,125,0,116,3,116,4,102,2,125,1,116,5,116,6,
102,2,125,2,124,0,124,1,124,2,103,3,83,0,41,1, 102,2,125,2,124,0,124,2,124,1,103,3,83,0,41,1,
122,95,82,101,116,117,114,110,115,32,97,32,108,105,115,116, 122,95,82,101,116,117,114,110,115,32,97,32,108,105,115,116,
32,111,102,32,102,105,108,101,45,98,97,115,101,100,32,109, 32,111,102,32,102,105,108,101,45,98,97,115,101,100,32,109,
111,100,117,108,101,32,108,111,97,100,101,114,115,46,10,10, 111,100,117,108,101,32,108,111,97,100,101,114,115,46,10,10,

View file

@ -307,6 +307,17 @@ import_init(PyInterpreterState *interp, PyObject *sysmod)
/* just add zip!.python/ to sys.path */ /* just add zip!.python/ to sys.path */
/* _PyImportZip_Init(); */ /* _PyImportZip_Init(); */
PyImport_ImportModule("_codecs");
PyImport_ImportModule("_collections");
PyImport_ImportModule("_functools");
PyImport_ImportModule("_heapq");
PyImport_ImportModule("_locale");
PyImport_ImportModule("_operator");
PyImport_ImportModule("_signal");
PyImport_ImportModule("_sre");
PyImport_ImportModule("_stat");
PyImport_ImportModule("errno");
PyImport_ImportModule("itertools");
} }

File diff suppressed because it is too large Load diff