1use crate::pytypedefs::PyThreadState;
2
3use core::ffi::{c_char, c_int};
4use libc::wchar_t;
5
6extern_libpython! {
7 pub fn Py_Initialize();
8 pub fn Py_InitializeEx(arg1: c_int);
9 pub fn Py_Finalize();
10 pub fn Py_FinalizeEx() -> c_int;
11
12 #[cfg_attr(PyPy, link_name = "PyPy_IsInitialized")]
13 pub fn Py_IsInitialized() -> c_int;
14
15 pub fn Py_NewInterpreter() -> *mut PyThreadState;
16 pub fn Py_EndInterpreter(arg1: *mut PyThreadState);
17
18 #[cfg_attr(PyPy, link_name = "PyPy_AtExit")]
19 pub fn Py_AtExit(func: Option<extern "C" fn()>) -> c_int;
20
21 pub fn Py_Exit(arg1: c_int) -> !;
22
23 pub fn Py_Main(argc: c_int, argv: *mut *mut wchar_t) -> c_int;
24 pub fn Py_BytesMain(argc: c_int, argv: *mut *mut c_char) -> c_int;
25
26 #[cfg_attr(
27 Py_3_11,
28 deprecated(note = "Deprecated since Python 3.11. Use `PyConfig.program_name` instead.")
29 )]
30 pub fn Py_SetProgramName(arg1: *const wchar_t);
31 #[cfg(not(Py_3_15))]
32 #[cfg_attr(PyPy, link_name = "PyPy_GetProgramName")]
33 #[cfg_attr(
34 Py_3_13,
35 deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.")
36 )]
37 pub fn Py_GetProgramName() -> *mut wchar_t;
38
39 #[cfg_attr(
40 Py_3_11,
41 deprecated(note = "Deprecated since Python 3.11. Use `PyConfig.home` instead.")
42 )]
43 pub fn Py_SetPythonHome(arg1: *const wchar_t);
44 #[cfg(not(Py_3_15))]
45 #[cfg_attr(
46 Py_3_13,
47 deprecated(
48 note = "Deprecated since Python 3.13. Use `PyConfig.home` or the value of the `PYTHONHOME` environment variable instead."
49 )
50 )]
51 pub fn Py_GetPythonHome() -> *mut wchar_t;
52 #[cfg(not(Py_3_15))]
53 #[cfg_attr(
54 Py_3_13,
55 deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.")
56 )]
57 pub fn Py_GetProgramFullPath() -> *mut wchar_t;
58 #[cfg(not(Py_3_15))]
59 #[cfg_attr(
60 Py_3_13,
61 deprecated(note = "Deprecated since Python 3.13. Use `sys.prefix` instead.")
62 )]
63 pub fn Py_GetPrefix() -> *mut wchar_t;
64 #[cfg(not(Py_3_15))]
65 #[cfg_attr(
66 Py_3_13,
67 deprecated(note = "Deprecated since Python 3.13. Use `sys.exec_prefix` instead.")
68 )]
69 pub fn Py_GetExecPrefix() -> *mut wchar_t;
70 #[cfg(not(Py_3_15))]
71 #[cfg_attr(
72 Py_3_13,
73 deprecated(note = "Deprecated since Python 3.13. Use `sys.path` instead.")
74 )]
75 pub fn Py_GetPath() -> *mut wchar_t;
76 #[cfg(not(Py_3_13))]
77 #[cfg_attr(
78 Py_3_11,
79 deprecated(note = "Deprecated since Python 3.11. Use `sys.path` instead.")
80 )]
81 pub fn Py_SetPath(arg1: *const wchar_t);
82
83 #[cfg_attr(PyPy, link_name = "PyPy_GetVersion")]
86 pub fn Py_GetVersion() -> *const c_char;
87 pub fn Py_GetPlatform() -> *const c_char;
88 pub fn Py_GetCopyright() -> *const c_char;
89 pub fn Py_GetCompiler() -> *const c_char;
90 pub fn Py_GetBuildInfo() -> *const c_char;
91}
92
93type PyOS_sighandler_t = unsafe extern "C" fn(arg1: c_int);
94
95extern_libpython! {
96 pub fn PyOS_getsig(arg1: c_int) -> PyOS_sighandler_t;
97 pub fn PyOS_setsig(arg1: c_int, arg2: PyOS_sighandler_t) -> PyOS_sighandler_t;
98
99 #[cfg(Py_3_11)]
100 pub static Py_Version: core::ffi::c_ulong;
101
102 #[cfg(Py_3_13)]
103 pub fn Py_IsFinalizing() -> c_int;
104}