-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to register a built-in extension module? #354
Comments
I made it https://github.com/kngwyu/pyo3/blob/append-init-tab-example/examples/word-count/src/main.rs But honestly I don't know when we should use |
Sidenote: It's normally better to use
Yes, |
@kngwyu: The solution I can up with is this: unsafe {
#[cfg(Py_2)]
let module_init = initmymodule;
#[cfg(Py_3)]
let module_init = PyInit_mymodule;
pyo3::ffi::PyImport_AppendInittab("mymodule\0".as_ptr() as *const c_char, Some(module_init));
} ...but I was wondering if there's a more elegant way to do it..
I hope not before 1/1/2020? |
No, definitely before. See https://python3statement.org/ |
As there has been no discussion on this question for some time, I'm going to close it. Thank you for the discussion. |
I have a Rust app that hosts Python interpreter. I want to register a built-in module so that Python code can call back into the app.
Not sure how to convert
#[pymodule] fn ...
, into something I can give toPyImport_AppendInittab
... Also, I need to support both Python 2 and 3, and it looks like I can't usewrap_pymodule!
with Python2?Would you mind providing an example?
The text was updated successfully, but these errors were encountered: