Skip to content

Commit

Permalink
Add more import APIs
Browse files Browse the repository at this point in the history
I need some of these APIs to support in-memory extension module
importing in PyOxidizer. While I was adding the ones I needed, I
figured I would include some other missing symbols from
import.h as well.
  • Loading branch information
indygreg committed Feb 25, 2020
1 parent 5b180f6 commit 8d2f857
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions python3-sys/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,24 @@ extern "C" {
pub static mut PyImport_Inittab: *mut _inittab;

pub fn PyImport_ExtendInittab(newtab: *const _inittab) -> c_int;

#[cfg(not(Py_3_7))]
pub fn _PyImport_FindBuiltin(name: *const c_char) -> *mut PyObject;
#[cfg(Py_3_7)]
pub fn _PyImport_FindBuiltin(name: *const c_char, modules: *mut PyObject) -> *mut PyObject;

pub fn _PyImport_FindExtensionObject(name: *mut PyObject, filename: *mut PyObject) -> *mut PyObject;

#[cfg(Py_3_7)]
pub fn _PyImport_FindExtensionObjectEx(name: *mut PyObject, filename: *mut PyObject, modules: *mut PyObject) -> *mut PyObject;

#[cfg(not(Py_3_7))]
pub fn _PyImport_FixupBuiltin(module: *mut PyObject, name: *const c_char) -> c_int;
#[cfg(Py_3_7)]
pub fn _PyImport_FixupBuiltin(module: *mut PyObject, name: *const c_char, modules: *mut PyObject) -> c_int;

#[cfg(not(Py_3_7))]
pub fn _PyImport_FixupExtensionObject(module: *mut PyObject, name: *mut PyObject, filename: *mut PyObject) -> c_int;
#[cfg(Py_3_7)]
pub fn _PyImport_FixupExtensionObject(module: *mut PyObject, name: *mut PyObject, filename: *mut PyObject, modules: *mut PyObject) -> c_int;
}
6 changes: 6 additions & 0 deletions python3-sys/src/modsupport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,9 @@ pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject
},
)
}

#[cfg(not(Py_LIMITED_API))]
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
pub static mut _Py_PackageContext: *const c_char;
}

0 comments on commit 8d2f857

Please sign in to comment.