@@ -536,6 +536,48 @@ Initializing and finalizing the interpreter
536536 first initialized).
537537
538538
539+ .. c:function:: int Py_FrozenMain(int argc, char **argv)
540+
541+ .. index :: single: freeze utility
542+
543+ The main program for a "frozen" Python program (an executable that embeds
544+ the interpreter together with the bytecode of the program's modules, as
545+ produced by the :program: `freeze ` utility; see :source: `Tools/freeze `).
546+
547+ This function initializes the interpreter, imports the frozen module named
548+ ``__main__``, and finalizes the interpreter.
549+ The frozen modules must have been registered in
550+ :c:var:`PyImport_FrozenModules` before calling this function;
551+ it is a fatal error if ``__main__ `` is not among them.
552+
553+ *argc * and *argv * are byte strings like the arguments of a C program's
554+ ``main `` function, and are passed to the interpreter with
555+ :c:func: `PyConfig_SetBytesArgv `.
556+ Unlike :c:func: `Py_Main `, the arguments are not parsed as Python command
557+ line options (:c:member: `PyConfig.parse_argv ` is ``0 ``), so all of them
558+ are made available to the program in :data:`sys.argv`.
559+ Apart from that, the interpreter uses the
560+ :ref:`Python Configuration <init-python-config>`, so environment variables
561+ such as :envvar:`PYTHONPATH` are honored.
562+ Warnings about the path configuration
563+ (:c:member: `PyConfig.pathconfig_warnings `) are suppressed.
564+ If :envvar:`PYTHONINSPECT` is set and standard input is a terminal, an
565+ interactive prompt is run after ``__main__`` has finished, as with the
566+ :option:`-i` option.
567+
568+ Return ``0`` if ``__main__`` ran without an unhandled exception, ``1``
569+ otherwise, and ``120`` if finalizing the interpreter failed (see
570+ :c:func: `Py_FinalizeEx `).
571+ An unhandled :exc:`SystemExit` terminates the process.
572+ If the interpreter cannot be initialized, the process exits via
573+ :c:func:`Py_ExitStatusException`.
574+
575+ On Windows, this function is not exported by the Python DLL.
576+ The :program:`freeze` utility compiles :file:`Python/frozenmain.c` into the
577+ frozen program instead, together with the Windows-specific hooks that the
578+ function requires.
579+
580+
539581.. c:function:: int Py_RunMain(void)
540582
541583 Executes the main module in a fully configured CPython runtime.
0 commit comments