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