@@ -608,6 +608,7 @@ Process-wide parameters
608608 .. index ::
609609 single: Py_Initialize()
610610 single: main()
611+ single: Py_GetPath()
611612
612613 This API is kept for backward compatibility: setting
613614 :c:member: `PyConfig.program_name ` should be used instead, see :ref: `Python
@@ -617,7 +618,7 @@ Process-wide parameters
617618 the first time, if it is called at all. It tells the interpreter the value
618619 of the ``argv[0] `` argument to the :c:func: `main ` function of the program
619620 (converted to wide characters).
620- This is used by some other functions below to find
621+ This is used by :c:func:`Py_GetPath` and some other functions below to find
621622 the Python run-time libraries relative to the interpreter executable. The
622623 default value is ``'python'``. The argument should point to a
623624 zero-terminated wide character string in static storage whose contents will not
@@ -630,6 +631,147 @@ Process-wide parameters
630631 .. deprecated-removed:: 3.11 3.15
631632
632633
634+ .. c:function:: wchar_t* Py_GetProgramName()
635+
636+ Return the program name set with :c:member:`PyConfig.program_name`, or the default.
637+ The returned string points into static storage; the caller should not modify its
638+ value.
639+
640+ This function should not be called before :c:func: `Py_Initialize `, otherwise
641+ it returns ``NULL ``.
642+
643+ .. versionchanged :: 3.10
644+ It now returns ``NULL `` if called before :c:func: `Py_Initialize `.
645+
646+ .. deprecated-removed :: 3.13 3.15
647+ Use :c:func: `PyConfig_Get("executable") <PyConfig_Get> `
648+ (:data: `sys.executable `) instead.
649+
650+
651+ .. c:function:: wchar_t* Py_GetPrefix()
652+
653+ Return the *prefix* for installed platform-independent files. This is derived
654+ through a number of complicated rules from the program name set with
655+ :c:member:`PyConfig.program_name` and some environment variables; for example, if the
656+ program name is ``'/usr/local/bin/python' ``, the prefix is ``'/usr/local' ``. The
657+ returned string points into static storage; the caller should not modify its
658+ value. This corresponds to the :makevar: `prefix ` variable in the top-level
659+ :file: `Makefile ` and the :option: `--prefix ` argument to the :program: `configure `
660+ script at build time. The value is available to Python code as ``sys.base_prefix ``.
661+ It is only useful on Unix. See also the next function.
662+
663+ This function should not be called before :c:func: `Py_Initialize `, otherwise
664+ it returns ``NULL ``.
665+
666+ .. versionchanged :: 3.10
667+ It now returns ``NULL `` if called before :c:func: `Py_Initialize `.
668+
669+ .. deprecated-removed :: 3.13 3.15
670+ Use :c:func: `PyConfig_Get("base_prefix") <PyConfig_Get> `
671+ (:data: `sys.base_prefix `) instead. Use :c:func:`PyConfig_Get("prefix")
672+ <PyConfig_Get>` (:data: `sys.prefix `) if :ref:`virtual environments
673+ <venv-def>` need to be handled.
674+
675+
676+ .. c:function:: wchar_t* Py_GetExecPrefix()
677+
678+ Return the *exec-prefix* for installed platform-*dependent* files. This is
679+ derived through a number of complicated rules from the program name set with
680+ :c:member:`PyConfig.program_name` and some environment variables; for example, if the
681+ program name is ``'/usr/local/bin/python' ``, the exec-prefix is
682+ ``'/usr/local' ``. The returned string points into static storage; the caller
683+ should not modify its value. This corresponds to the :makevar: `exec_prefix `
684+ variable in the top-level :file: `Makefile ` and the ``--exec-prefix ``
685+ argument to the :program: `configure ` script at build time. The value is
686+ available to Python code as ``sys.base_exec_prefix ``. It is only useful on
687+ Unix.
688+
689+ Background: The exec-prefix differs from the prefix when platform dependent
690+ files (such as executables and shared libraries) are installed in a different
691+ directory tree. In a typical installation, platform dependent files may be
692+ installed in the :file: `/usr/local/plat ` subtree while platform independent may
693+ be installed in :file: `/usr/local `.
694+
695+ Generally speaking, a platform is a combination of hardware and software
696+ families, e.g. Sparc machines running the Solaris 2.x operating system are
697+ considered the same platform, but Intel machines running Solaris 2.x are another
698+ platform, and Intel machines running Linux are yet another platform. Different
699+ major revisions of the same operating system generally also form different
700+ platforms. Non-Unix operating systems are a different story; the installation
701+ strategies on those systems are so different that the prefix and exec-prefix are
702+ meaningless, and set to the empty string. Note that compiled Python bytecode
703+ files are platform independent (but not independent from the Python version by
704+ which they were compiled!).
705+
706+ System administrators will know how to configure the :program: `mount ` or
707+ :program: `automount ` programs to share :file: `/usr/local ` between platforms
708+ while having :file: `/usr/local/plat ` be a different filesystem for each
709+ platform.
710+
711+ This function should not be called before :c:func: `Py_Initialize `, otherwise
712+ it returns ``NULL ``.
713+
714+ .. versionchanged :: 3.10
715+ It now returns ``NULL `` if called before :c:func: `Py_Initialize `.
716+
717+ .. deprecated-removed :: 3.13 3.15
718+ Use :c:func: `PyConfig_Get("base_exec_prefix") <PyConfig_Get> `
719+ (:data: `sys.base_exec_prefix `) instead. Use
720+ :c:func: `PyConfig_Get("exec_prefix") <PyConfig_Get> `
721+ (:data: `sys.exec_prefix `) if :ref: `virtual environments <venv-def >` need
722+ to be handled.
723+
724+
725+ .. c :function :: wchar_t * Py_GetProgramFullPath ()
726+
727+ .. index::
728+ single: executable (in module sys)
729+
730+ Return the full program name of the Python executable; this is computed as a
731+ side-effect of deriving the default module search path from the program name
732+ (set by :c:member: `PyConfig.program_name `). The returned string points into
733+ static storage; the caller should not modify its value. The value is available
734+ to Python code as ``sys.executable ``.
735+
736+ This function should not be called before :c:func: `Py_Initialize `, otherwise
737+ it returns ``NULL ``.
738+
739+ .. versionchanged :: 3.10
740+ It now returns ``NULL `` if called before :c:func: `Py_Initialize `.
741+
742+ .. deprecated-removed :: 3.13 3.15
743+ Use :c:func: `PyConfig_Get("executable") <PyConfig_Get> `
744+ (:data: `sys.executable `) instead.
745+
746+
747+ .. c :function :: wchar_t * Py_GetPath ()
748+
749+ .. index::
750+ triple: module; search; path
751+ single: path (in module sys)
752+
753+ Return the default module search path; this is computed from the program name
754+ (set by :c:member: `PyConfig.program_name `) and some environment variables.
755+ The returned string consists of a series of directory names separated by a
756+ platform dependent delimiter character. The delimiter character is ``':' ``
757+ on Unix and macOS, ``';' `` on Windows. The returned string points into
758+ static storage; the caller should not modify its value. The list
759+ :data: `sys.path ` is initialized with this value on interpreter startup; it
760+ can be (and usually is) modified later to change the search path for loading
761+ modules.
762+
763+ This function should not be called before :c:func: `Py_Initialize `, otherwise
764+ it returns ``NULL ``.
765+
766+ .. XXX should give the exact rules
767+
768+ .. versionchanged :: 3.10
769+ It now returns ``NULL `` if called before :c:func: `Py_Initialize `.
770+
771+ .. deprecated-removed :: 3.13 3.15
772+ Use :c:func: `PyConfig_Get("module_search_paths") <PyConfig_Get> `
773+ (:data: `sys.path `) instead.
774+
633775.. c :function :: const char * Py_GetVersion ()
634776
635777 Return the version of this Python interpreter. This is a string that looks
@@ -795,3 +937,20 @@ Process-wide parameters
795937 :c:expr:`wchar_t*` string.
796938
797939 .. deprecated-removed:: 3.11 3.15
940+
941+
942+ .. c:function:: wchar_t* Py_GetPythonHome()
943+
944+ Return the default " home" , that is, the value set by
945+ :c:member:`PyConfig.home`, or the value of the :envvar:`PYTHONHOME`
946+ environment variable if it is set.
947+
948+ This function should not be called before :c:func:`Py_Initialize`, otherwise
949+ it returns ``NULL``.
950+
951+ .. versionchanged:: 3.10
952+ It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
953+
954+ .. deprecated-removed:: 3.13 3.15
955+ Use :c:func:`PyConfig_Get(" home" ) <PyConfig_Get>` or the
956+ :envvar:`PYTHONHOME` environment variable instead.
0 commit comments