mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-33499: Add PYTHONPYCACHEPREFIX env var for alt bytecode cache location. (GH-6834)
In some development setups it is inconvenient or impossible to write bytecode caches to the code tree, but the bytecode caches are still useful. The PYTHONPYCACHEPREFIX environment variable allows specifying an alternate location for cached bytecode files, within which a directory tree mirroring the code tree will be created. This cache tree is then used (for both reading and writing) instead of the local `__pycache__` subdirectory within each source directory. Exposed at runtime as sys.pycache_prefix (defaulting to None), and can be set from the CLI as "-X pycache_prefix=path". Patch by Carl Meyer.
This commit is contained in:
parent
6868003514
commit
b193fa996a
12 changed files with 1386 additions and 1087 deletions
|
@ -2458,6 +2458,12 @@ _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config)
|
|||
SET_SYS_FROM_STRING_BORROW("exec_prefix", config->exec_prefix);
|
||||
SET_SYS_FROM_STRING_BORROW("base_exec_prefix", config->base_exec_prefix);
|
||||
|
||||
if (config->pycache_prefix != NULL) {
|
||||
SET_SYS_FROM_STRING_BORROW("pycache_prefix", config->pycache_prefix);
|
||||
} else {
|
||||
PyDict_SetItemString(sysdict, "pycache_prefix", Py_None);
|
||||
}
|
||||
|
||||
if (config->argv != NULL) {
|
||||
SET_SYS_FROM_STRING_BORROW("argv", config->argv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue