mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
PEP 302 + zipimport:
- new import hooks in import.c, exposed in the sys module - new module called 'zipimport' - various changes to allow bootstrapping from zip files I hope I didn't break the Windows build (or anything else for that matter), but then again, it's been sitting on sf long enough... Regarding the latest discussions on python-dev: zipimport sets pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as /path/to/Archive.zip/subdir/ are supported again.
This commit is contained in:
parent
60087fb450
commit
52e14d640b
13 changed files with 1887 additions and 35 deletions
|
@ -365,6 +365,7 @@ calculate_path(void)
|
|||
char *path = getenv("PATH");
|
||||
char *prog = Py_GetProgramName();
|
||||
char argv0_path[MAXPATHLEN+1];
|
||||
char zip_path[MAXPATHLEN+1];
|
||||
int pfound, efound; /* 1 if found; -1 if found build directory */
|
||||
char *buf;
|
||||
size_t bufsz;
|
||||
|
@ -483,6 +484,18 @@ calculate_path(void)
|
|||
else
|
||||
reduce(prefix);
|
||||
|
||||
strncpy(zip_path, prefix, MAXPATHLEN);
|
||||
if (pfound > 0) { /* Use the reduced prefix returned by Py_GetPrefix() */
|
||||
reduce(zip_path);
|
||||
reduce(zip_path);
|
||||
}
|
||||
else
|
||||
strncpy(zip_path, PREFIX, MAXPATHLEN);
|
||||
joinpath(zip_path, "lib/python00.zip");
|
||||
bufsz = strlen(zip_path); /* Replace "00" with version */
|
||||
zip_path[bufsz - 6] = VERSION[0];
|
||||
zip_path[bufsz - 5] = VERSION[2];
|
||||
|
||||
if (!(efound = search_for_exec_prefix(argv0_path, home))) {
|
||||
if (!Py_FrozenFlag)
|
||||
fprintf(stderr,
|
||||
|
@ -521,6 +534,7 @@ calculate_path(void)
|
|||
defpath = delim + 1;
|
||||
}
|
||||
|
||||
bufsz += strlen(zip_path) + 1;
|
||||
bufsz += strlen(exec_prefix) + 1;
|
||||
|
||||
/* This is the only malloc call in this file */
|
||||
|
@ -541,6 +555,10 @@ calculate_path(void)
|
|||
else
|
||||
buf[0] = '\0';
|
||||
|
||||
/* Next is the default zip path */
|
||||
strcat(buf, zip_path);
|
||||
strcat(buf, delimiter);
|
||||
|
||||
/* Next goes merge of compile-time $PYTHONPATH with
|
||||
* dynamically located prefix.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue