Rename prepare_pyo3_library to init_once

This commit is contained in:
konstin 2018-07-03 21:12:57 +02:00
parent 1e31fc4451
commit 43eb5fa490
3 changed files with 10 additions and 10 deletions

View File

@ -22,7 +22,7 @@ pub fn py3_init(fnname: &syn::Ident, name: &syn::Ident, doc: syn::Lit) -> TokenS
use ::pyo3::{IntoPyPointer, ObjectProtocol};
// initialize pyo3
::pyo3::prepare_pyo3_library();
::pyo3::init_once();
static mut MODULE_DEF: ::pyo3::ffi::PyModuleDef = ::pyo3::ffi::PyModuleDef_INIT;
// We can't convert &'static str to *const c_char within a static initializer,
@ -67,7 +67,7 @@ pub fn py2_init(fnname: &syn::Ident, name: &syn::Ident, doc: syn::Lit) -> TokenS
#[allow(non_snake_case, unused_imports)]
pub unsafe extern "C" fn #cb_name() {
// initialize python
::pyo3::prepare_pyo3_library();
::pyo3::init_once();
::pyo3::ffi::PyEval_InitThreads();
let _name = concat!(stringify!(#name), "\0").as_ptr() as *const _;

View File

@ -164,7 +164,7 @@ pub use object::PyObject;
pub use noargs::NoArgs;
pub use typeob::{PyTypeInfo, PyRawObject, PyObjectAlloc};
pub use python::{Python, ToPyPointer, IntoPyPointer, IntoPyDictPointer};
pub use pythonrun::{GILGuard, GILPool, prepare_freethreaded_python, prepare_pyo3_library};
pub use pythonrun::{GILGuard, GILPool, prepare_freethreaded_python, init_once};
pub use instance::{PyToken, PyObjectWithToken, AsPyRef, Py, PyNativeType};
pub use conversion::{FromPyObject, PyTryFrom, PyTryInto,
ToPyObject, ToBorrowedObject, IntoPyObject, IntoPyTuple,

View File

@ -61,13 +61,13 @@ pub fn prepare_freethreaded_python() {
// and will be restored by PyGILState_Ensure.
}
prepare_pyo3_library();
init_once();
});
}
#[doc(hidden)]
pub fn prepare_pyo3_library() {
pub fn init_once() {
START_PYO3.call_once(|| unsafe {
// initialize release pool
POOL = Box::into_raw(Box::new(ReleasePool::new()));
@ -282,7 +282,7 @@ mod test {
#[test]
fn test_owned() {
pythonrun::prepare_pyo3_library();
pythonrun::init_once();
unsafe {
let p: &'static mut ReleasePool = &mut *POOL;
@ -309,7 +309,7 @@ mod test {
#[test]
fn test_owned_nested() {
pythonrun::prepare_pyo3_library();
pythonrun::init_once();
let gil = Python::acquire_gil();
let py = gil.python();
@ -346,7 +346,7 @@ mod test {
#[test]
fn test_borrowed() {
pythonrun::prepare_pyo3_library();
pythonrun::init_once();
unsafe {
let p: &'static mut ReleasePool = &mut *POOL;
@ -373,7 +373,7 @@ mod test {
#[test]
fn test_borrowed_nested() {
pythonrun::prepare_pyo3_library();
pythonrun::init_once();
unsafe {
let p: &'static mut ReleasePool = &mut *POOL;
@ -410,7 +410,7 @@ mod test {
#[test]
fn test_pyobject_drop() {
pythonrun::prepare_pyo3_library();
pythonrun::init_once();
unsafe {
let p: &'static mut ReleasePool = &mut *POOL;