Commit 88feaecd authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-38234: Complete init config documentation (GH-16404)

parent 8bf39b60
...@@ -241,6 +241,7 @@ PyPreConfig ...@@ -241,6 +241,7 @@ PyPreConfig
locale to decide if it should be coerced. locale to decide if it should be coerced.
.. c:member:: int coerce_c_locale_warn .. c:member:: int coerce_c_locale_warn
If non-zero, emit a warning if the C locale is coerced. If non-zero, emit a warning if the C locale is coerced.
.. c:member:: int dev_mode .. c:member:: int dev_mode
...@@ -300,7 +301,7 @@ For :ref:`Python Configuration <init-python-config>` ...@@ -300,7 +301,7 @@ For :ref:`Python Configuration <init-python-config>`
(:c:func:`PyPreConfig_InitPythonConfig`), if Python is initialized with (:c:func:`PyPreConfig_InitPythonConfig`), if Python is initialized with
command line arguments, the command line arguments must also be passed to command line arguments, the command line arguments must also be passed to
preinitialize Python, since they have an effect on the pre-configuration preinitialize Python, since they have an effect on the pre-configuration
like encodings. For example, the :option:`-X` ``utf8`` command line option like encodings. For example, the :option:`-X utf8 <-X>` command line option
enables the UTF-8 Mode. enables the UTF-8 Mode.
``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and ``PyMem_SetAllocator()`` can be called after :c:func:`Py_PreInitialize` and
...@@ -464,7 +465,7 @@ PyConfig ...@@ -464,7 +465,7 @@ PyConfig
.. c:member:: int dev_mode .. c:member:: int dev_mode
Development mode: see :option:`-X` ``dev``. Development mode: see :option:`-X dev <-X>`.
.. c:member:: int dump_refs .. c:member:: int dump_refs
...@@ -482,7 +483,7 @@ PyConfig ...@@ -482,7 +483,7 @@ PyConfig
.. c:member:: int faulthandler .. c:member:: int faulthandler
If non-zero, call :func:`faulthandler.enable`. If non-zero, call :func:`faulthandler.enable` at startup.
.. c:member:: wchar_t* filesystem_encoding .. c:member:: wchar_t* filesystem_encoding
...@@ -504,6 +505,9 @@ PyConfig ...@@ -504,6 +505,9 @@ PyConfig
Python home directory. Python home directory.
Initialized from :envvar:`PYTHONHOME` environment variable value by
default.
.. c:member:: int import_time .. c:member:: int import_time
If non-zero, profile import time. If non-zero, profile import time.
...@@ -561,7 +565,7 @@ PyConfig ...@@ -561,7 +565,7 @@ PyConfig
:data:`sys.path`. If :c:member:`~PyConfig.module_search_paths_set` is :data:`sys.path`. If :c:member:`~PyConfig.module_search_paths_set` is
equal to 0, the :c:member:`~PyConfig.module_search_paths` is overridden equal to 0, the :c:member:`~PyConfig.module_search_paths` is overridden
by the function computing the :ref:`Path Configuration by the function calculating the :ref:`Path Configuration
<init-path-config>`. <init-path-config>`.
.. c:member:: int optimization_level .. c:member:: int optimization_level
...@@ -586,9 +590,9 @@ PyConfig ...@@ -586,9 +590,9 @@ PyConfig
.. c:member:: int pathconfig_warnings .. c:member:: int pathconfig_warnings
If equal to 0, suppress warnings when computing the path configuration If equal to 0, suppress warnings when calculating the :ref:`Path
(Unix only, Windows does not log any warning). Otherwise, warnings are Configuration <init-path-config>` (Unix only, Windows does not log any
written into ``stderr``. warning). Otherwise, warnings are written into ``stderr``.
.. c:member:: wchar_t* prefix .. c:member:: wchar_t* prefix
...@@ -596,39 +600,46 @@ PyConfig ...@@ -596,39 +600,46 @@ PyConfig
.. c:member:: wchar_t* program_name .. c:member:: wchar_t* program_name
Program name. Program name. Used to initialize :c:member:`~PyConfig.executable`, and in
early error messages.
.. c:member:: wchar_t* pycache_prefix .. c:member:: wchar_t* pycache_prefix
``.pyc`` cache prefix. :data:`sys.pycache_prefix`: ``.pyc`` cache prefix.
If NULL, :data:`sys.pycache_prefix` is set to ``None``.
.. c:member:: int quiet .. c:member:: int quiet
Quiet mode. For example, don't display the copyright and version messages Quiet mode. For example, don't display the copyright and version messages
even in interactive mode. in interactive mode.
.. c:member:: wchar_t* run_command .. c:member:: wchar_t* run_command
``python3 -c COMMAND`` argument. ``python3 -c COMMAND`` argument. Used by :c:func:`Py_RunMain`.
.. c:member:: wchar_t* run_filename .. c:member:: wchar_t* run_filename
``python3 FILENAME`` argument. ``python3 FILENAME`` argument. Used by :c:func:`Py_RunMain`.
.. c:member:: wchar_t* run_module .. c:member:: wchar_t* run_module
``python3 -m MODULE`` argument. ``python3 -m MODULE`` argument. Used by :c:func:`Py_RunMain`.
.. c:member:: int show_alloc_count .. c:member:: int show_alloc_count
Show allocation counts at exit? Show allocation counts at exit?
Set to 1 by :option:`-X showalloccount <-X>` command line option.
Need a special Python build with ``COUNT_ALLOCS`` macro defined. Need a special Python build with ``COUNT_ALLOCS`` macro defined.
.. c:member:: int show_ref_count .. c:member:: int show_ref_count
Show total reference count at exit? Show total reference count at exit?
Set to 1 by :option:`-X showrefcount <-X>` command line option.
Need a debug build of Python (``Py_REF_DEBUG`` macro must be defined). Need a debug build of Python (``Py_REF_DEBUG`` macro must be defined).
.. c:member:: int site_import .. c:member:: int site_import
...@@ -647,7 +658,7 @@ PyConfig ...@@ -647,7 +658,7 @@ PyConfig
.. c:member:: int tracemalloc .. c:member:: int tracemalloc
If non-zero, call :func:`tracemalloc.start`. If non-zero, call :func:`tracemalloc.start` at startup.
.. c:member:: int use_environment .. c:member:: int use_environment
...@@ -669,6 +680,9 @@ PyConfig ...@@ -669,6 +680,9 @@ PyConfig
If non-zero, write ``.pyc`` files. If non-zero, write ``.pyc`` files.
:data:`sys.dont_write_bytecode` is initialized to the inverted value of
:c:member:`~PyConfig.write_bytecode`.
.. c:member:: PyWideStringList xoptions .. c:member:: PyWideStringList xoptions
:data:`sys._xoptions`. :data:`sys._xoptions`.
...@@ -694,8 +708,8 @@ Function to initialize Python: ...@@ -694,8 +708,8 @@ Function to initialize Python:
The caller is responsible to handle exceptions (error or exit) using The caller is responsible to handle exceptions (error or exit) using
:c:func:`PyStatus_Exception` and :c:func:`Py_ExitStatusException`. :c:func:`PyStatus_Exception` and :c:func:`Py_ExitStatusException`.
``PyImport_FrozenModules``, ``PyImport_AppendInittab()`` or If ``PyImport_FrozenModules``, ``PyImport_AppendInittab()`` or
``PyImport_ExtendInittab()`` is used: they must be set or called after Python ``PyImport_ExtendInittab()`` are used, they must be set or called after Python
preinitialization and before the Python initialization. preinitialization and before the Python initialization.
Example setting the program name:: Example setting the program name::
...@@ -760,7 +774,7 @@ configuration, and then override some parameters:: ...@@ -760,7 +774,7 @@ configuration, and then override some parameters::
/* Append our custom search path to sys.path */ /* Append our custom search path to sys.path */
status = PyWideStringList_Append(&config.module_search_paths, status = PyWideStringList_Append(&config.module_search_paths,
L"/path/to/more/modules"); L"/path/to/more/modules");
if (PyStatus_Exception(status)) { if (PyStatus_Exception(status)) {
goto done; goto done;
} }
...@@ -791,9 +805,9 @@ isolate Python from the system. For example, to embed Python into an ...@@ -791,9 +805,9 @@ isolate Python from the system. For example, to embed Python into an
application. application.
This configuration ignores global configuration variables, environments This configuration ignores global configuration variables, environments
variables and command line arguments (:c:member:`PyConfig.argv` is not parsed). variables, command line arguments (:c:member:`PyConfig.argv` is not parsed)
The C standard streams (ex: ``stdout``) and the LC_CTYPE locale are left and user site directory. The C standard streams (ex: ``stdout``) and the
unchanged by default. LC_CTYPE locale are left unchanged. Signal handlers are not installed.
Configuration files are still used with this configuration. Set the Configuration files are still used with this configuration. Set the
:ref:`Path Configuration <init-path-config>` ("output fields") to ignore these :ref:`Path Configuration <init-path-config>` ("output fields") to ignore these
...@@ -970,7 +984,7 @@ initialization, the core feature of the :pep:`432`: ...@@ -970,7 +984,7 @@ initialization, the core feature of the :pep:`432`:
* Builtin exceptions; * Builtin exceptions;
* Builtin and frozen modules; * Builtin and frozen modules;
* The :mod:`sys` module is only partially initialized * The :mod:`sys` module is only partially initialized
(ex: :data:`sys.path` doesn't exist yet); (ex: :data:`sys.path` doesn't exist yet).
* "Main" initialization phase, Python is fully initialized: * "Main" initialization phase, Python is fully initialized:
...@@ -996,9 +1010,9 @@ No module is imported during the "Core" phase and the ``importlib`` module is ...@@ -996,9 +1010,9 @@ No module is imported during the "Core" phase and the ``importlib`` module is
not configured: the :ref:`Path Configuration <init-path-config>` is only not configured: the :ref:`Path Configuration <init-path-config>` is only
applied during the "Main" phase. It may allow to customize Python in Python to applied during the "Main" phase. It may allow to customize Python in Python to
override or tune the :ref:`Path Configuration <init-path-config>`, maybe override or tune the :ref:`Path Configuration <init-path-config>`, maybe
install a custom sys.meta_path importer or an import hook, etc. install a custom :data:`sys.meta_path` importer or an import hook, etc.
It may become possible to compute the :ref:`Path Configuration It may become possible to calculatin the :ref:`Path Configuration
<init-path-config>` in Python, after the Core phase and before the Main phase, <init-path-config>` in Python, after the Core phase and before the Main phase,
which is one of the :pep:`432` motivation. which is one of the :pep:`432` motivation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment