1use crate::pystate::PyThreadState;
2
3use libc::wchar_t;
4use std::os::raw::{c_char, c_int};
5
6extern "C" {
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_attr(PyPy, link_name = "PyPy_GetProgramName")]
32 #[cfg_attr(
33 Py_3_13,
34 deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.")
35 )]
36 pub fn Py_GetProgramName() -> *mut wchar_t;
37
38 #[cfg_attr(
39 Py_3_11,
40 deprecated(note = "Deprecated since Python 3.11. Use `PyConfig.home` instead.")
41 )]
42 pub fn Py_SetPythonHome(arg1: *const wchar_t);
43 #[cfg_attr(
44 Py_3_13,
45 deprecated(
46 note = "Deprecated since Python 3.13. Use `PyConfig.home` or the value of the `PYTHONHOME` environment variable instead."
47 )
48 )]
49 pub fn Py_GetPythonHome() -> *mut wchar_t;
50 #[cfg_attr(
51 Py_3_13,
52 deprecated(note = "Deprecated since Python 3.13. Use `sys.executable` instead.")
53 )]
54 pub fn Py_GetProgramFullPath() -> *mut wchar_t;
55 #[cfg_attr(
56 Py_3_13,
57 deprecated(note = "Deprecated since Python 3.13. Use `sys.prefix` instead.")
58 )]
59 pub fn Py_GetPrefix() -> *mut wchar_t;
60 #[cfg_attr(
61 Py_3_13,
62 deprecated(note = "Deprecated since Python 3.13. Use `sys.exec_prefix` instead.")
63 )]
64 pub fn Py_GetExecPrefix() -> *mut wchar_t;
65 #[cfg_attr(
66 Py_3_13,
67 deprecated(note = "Deprecated since Python 3.13. Use `sys.path` instead.")
68 )]
69 pub fn Py_GetPath() -> *mut wchar_t;
70 #[cfg(not(Py_3_13))]
71 #[cfg_attr(
72 Py_3_11,
73 deprecated(note = "Deprecated since Python 3.11. Use `sys.path` instead.")
74 )]
75 pub fn Py_SetPath(arg1: *const wchar_t);
76
77 #[cfg_attr(PyPy, link_name = "PyPy_GetVersion")]
80 pub fn Py_GetVersion() -> *const c_char;
81 pub fn Py_GetPlatform() -> *const c_char;
82 pub fn Py_GetCopyright() -> *const c_char;
83 pub fn Py_GetCompiler() -> *const c_char;
84 pub fn Py_GetBuildInfo() -> *const c_char;
85}
86
87type PyOS_sighandler_t = unsafe extern "C" fn(arg1: c_int);
88
89extern "C" {
90 pub fn PyOS_getsig(arg1: c_int) -> PyOS_sighandler_t;
91 pub fn PyOS_setsig(arg1: c_int, arg2: PyOS_sighandler_t) -> PyOS_sighandler_t;
92}