mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-110722: Add PYTHON_PRESITE to import a module before site.py is run (#110769)
This commit is contained in:
parent
ab08ff7882
commit
84b7e9e3fa
8 changed files with 178 additions and 7 deletions
|
@ -552,6 +552,12 @@ Miscellaneous options
|
|||
This option may be useful for users who need to limit CPU resources of a
|
||||
container system. See also :envvar:`PYTHON_CPU_COUNT`.
|
||||
If *n* is ``default``, nothing is overridden.
|
||||
* :samp:`-X presite={package.module}` specifies a module that should be
|
||||
imported before the :mod:`site` module is executed and before the
|
||||
:mod:`__main__` module exists. Therefore, the imported module isn't
|
||||
:mod:`__main__`. This can be used to execute code early during Python
|
||||
initialization. Python needs to be :ref:`built in debug mode <debug-build>`
|
||||
for this option to exist. See also :envvar:`PYTHON_PRESITE`.
|
||||
|
||||
It also allows passing arbitrary values and retrieving them through the
|
||||
:data:`sys._xoptions` dictionary.
|
||||
|
@ -602,6 +608,9 @@ Miscellaneous options
|
|||
.. versionadded:: 3.13
|
||||
The ``-X cpu_count`` option.
|
||||
|
||||
.. versionadded:: 3.13
|
||||
The ``-X presite`` option.
|
||||
|
||||
|
||||
Options you shouldn't use
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -1091,13 +1100,33 @@ Debug-mode variables
|
|||
If set, Python will dump objects and reference counts still alive after
|
||||
shutting down the interpreter.
|
||||
|
||||
Need Python configured with the :option:`--with-trace-refs` build option.
|
||||
Needs Python configured with the :option:`--with-trace-refs` build option.
|
||||
|
||||
.. envvar:: PYTHONDUMPREFSFILE=FILENAME
|
||||
.. envvar:: PYTHONDUMPREFSFILE
|
||||
|
||||
If set, Python will dump objects and reference counts still alive
|
||||
after shutting down the interpreter into a file called *FILENAME*.
|
||||
after shutting down the interpreter into a file under the path given
|
||||
as the value to this environment variable.
|
||||
|
||||
Need Python configured with the :option:`--with-trace-refs` build option.
|
||||
Needs Python configured with the :option:`--with-trace-refs` build option.
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
.. envvar:: PYTHON_PRESITE
|
||||
|
||||
If this variable is set to a module, that module will be imported
|
||||
early in the interpreter lifecycle, before the :mod:`site` module is
|
||||
executed, and before the :mod:`__main__` module is created.
|
||||
Therefore, the imported module is not treated as :mod:`__main__`.
|
||||
|
||||
This can be used to execute code early during Python initialization.
|
||||
|
||||
To import a submodule, use ``package.module`` as the value, like in
|
||||
an import statement.
|
||||
|
||||
See also the :option:`-X presite <-X>` command-line option,
|
||||
which takes precedence over this variable.
|
||||
|
||||
Needs Python configured with the :option:`--with-pydebug` build option.
|
||||
|
||||
.. versionadded:: 3.13
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue