mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -209,6 +209,26 @@ always available.
|
|||
yourself to control bytecode file generation.
|
||||
|
||||
|
||||
.. data:: pycache_prefix
|
||||
|
||||
If this is set (not ``None``), Python will write bytecode-cache ``.pyc``
|
||||
files to (and read them from) a parallel directory tree rooted at this
|
||||
directory, rather than from ``__pycache__`` directories in the source code
|
||||
tree. Any ``__pycache__`` directories in the source code tree will be ignored
|
||||
and new `.pyc` files written within the pycache prefix. Thus if you use
|
||||
:mod:`compileall` as a pre-build step, you must ensure you run it with the
|
||||
same pycache prefix (if any) that you will use at runtime.
|
||||
|
||||
A relative path is interpreted relative to the current working directory.
|
||||
|
||||
This value is initially set based on the value of the :option:`-X`
|
||||
``pycache_prefix=PATH`` command-line option or the
|
||||
:envvar:`PYTHONPYCACHEPREFIX` environment variable (command-line takes
|
||||
precedence). If neither are set, it is ``None``.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
|
||||
|
||||
.. function:: excepthook(type, value, traceback)
|
||||
|
||||
This function prints out a given traceback and exception to ``sys.stderr``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue