Skip to main content

pyo3_ffi/cpython/
import.rs

1#[cfg(any(not(PyPy), Py_3_14))]
2use crate::PyObject;
3#[cfg(any(not(PyPy), Py_3_14))]
4use std::ffi::c_char;
5#[cfg(not(PyPy))]
6use std::ffi::{c_int, c_uchar};
7
8#[cfg(not(PyPy))]
9#[repr(C)]
10#[derive(Copy, Clone)]
11pub struct _inittab {
12    pub name: *const c_char,
13    pub initfunc: Option<unsafe extern "C" fn() -> *mut PyObject>,
14}
15
16extern_libpython! {
17    #[cfg(not(PyPy))]
18    pub static mut PyImport_Inittab: *mut _inittab;
19
20    #[cfg(not(PyPy))]
21    pub fn PyImport_ExtendInittab(newtab: *mut _inittab) -> c_int;
22}
23
24#[cfg(not(PyPy))]
25#[repr(C)]
26#[derive(Copy, Clone)]
27pub struct _frozen {
28    pub name: *const c_char,
29    pub code: *const c_uchar,
30    pub size: c_int,
31    #[cfg(Py_3_11)]
32    pub is_package: c_int,
33    #[cfg(all(Py_3_11, not(Py_3_13)))]
34    pub get_code: Option<unsafe extern "C" fn() -> *mut PyObject>,
35}
36
37extern_libpython! {
38    #[cfg(not(PyPy))]
39    pub static mut PyImport_FrozenModules: *const _frozen;
40
41    #[cfg(Py_3_14)]
42    pub fn PyImport_ImportModuleAttr(
43        mod_name: *mut PyObject,
44        attr_name: *mut PyObject,
45    ) -> *mut PyObject;
46    #[cfg(Py_3_14)]
47    pub fn PyImport_ImportModuleAttrString(
48        mod_name: *const c_char,
49        attr_name: *const c_char,
50    ) -> *mut PyObject;
51}