Skip to content
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

[DO NOT MERGE] [#2359]Add macro append_to_inittab #2362

Closed
wants to merge 0 commits into from

Conversation

herquan
Copy link
Contributor

@herquan herquan commented May 10, 2022

Sometimes we need to debug in a real environment with our module installed. append_to_inittab will be a wrapper for PyImport_AppendInittab (https://docs.python.org/3/c-api/import.html#c.PyImport_AppendInittab) and help us to do this

So far I'm not sure how to use #krate in macro rather than hard coded pyo3. I wonder if anyone have any suggestion how to achieve this?

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It's actually very hard to use #krate in function-like proc macros.

You might want to take a look at #2363 and rebase on top of it? Then you should be able to write a macro_rules macro in the same way as those wrap macros.

@@ -76,6 +76,6 @@ extern "C" {

pub fn PyImport_AppendInittab(
name: *const c_char,
initfunc: Option<extern "C" fn() -> *mut PyObject>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2363 looks like a better approach. I will wait until that is merged.

@davidhewitt
Copy link
Member

Errrgh sorry, #2363 doesn't quite work as I hoped. What you should be able to do, though, is after #2366 you can put the exports from pyo3 that you need inside the #[pymodule] generated-module, circumventing the need to use anything from pyo3 directly.

@davidhewitt
Copy link
Member

Sorry I did a u-turn and will proceed with #2363 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants