-
Notifications
You must be signed in to change notification settings - Fork 803
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
Move macros into separate feature. #897
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,21 +150,18 @@ pub use crate::type_object::{type_flags, PyTypeInfo}; | |
// Since PyAny is as important as PyObject, we expose it to the top level. | ||
pub use crate::types::PyAny; | ||
|
||
// Re-exported for wrap_function | ||
#[cfg(feature = "macros")] | ||
#[doc(hidden)] | ||
pub use paste; | ||
// Re-exported for py_run | ||
#[doc(hidden)] | ||
pub use indoc; | ||
// Re-exported for pymethods | ||
#[doc(hidden)] | ||
pub use inventory; | ||
pub use { | ||
indoc, // Re-exported for py_run | ||
inventory, // Re-exported for pymethods | ||
paste, // Re-exported for wrap_function | ||
unindent, // Re-exported for py_run | ||
}; | ||
|
||
// Re-exported for the `__wrap` functions | ||
#[doc(hidden)] | ||
pub use libc; | ||
// Re-exported for py_run | ||
#[doc(hidden)] | ||
pub use unindent; | ||
|
||
pub mod buffer; | ||
#[doc(hidden)] | ||
|
@@ -197,6 +194,7 @@ pub mod type_object; | |
pub mod types; | ||
|
||
/// The proc macros, which are also part of the prelude. | ||
#[cfg(feature = "macros")] | ||
pub mod proc_macro { | ||
pub use pyo3cls::pymodule; | ||
/// The proc macro attributes | ||
|
@@ -278,6 +276,7 @@ macro_rules! wrap_pymodule { | |
/// If you need to handle failures, please use [Python::run] directly. | ||
/// | ||
#[macro_export] | ||
#[cfg(feature = "macros")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry for my lazy review but could you please add this definition? #[macro_export]
#[cfg(not(feature = "macros"))]
macro_rules! py_run {
($py:expr, $($val:ident)+, $code:expr) => {{
pyo3::py_run_impl!($py, $($val)+, &pyo3::unindent::unindent($code))
}};
}
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would mean that code like let code = "asdf";
py_run!(py, a b, code); would compile fine with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, it behaves the same.
it works faster thanks to indoc. |
||
macro_rules! py_run { | ||
($py:expr, $($val:ident)+, $code:literal) => {{ | ||
pyo3::py_run_impl!($py, $($val)+, pyo3::indoc::indoc!($code)) | ||
|
@@ -289,6 +288,7 @@ macro_rules! py_run { | |
|
||
#[macro_export] | ||
#[doc(hidden)] | ||
#[cfg(feature = "macros")] | ||
macro_rules! py_run_impl { | ||
($py:expr, $($val:ident)+, $code:expr) => {{ | ||
use pyo3::types::IntoPyDict; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍