Replies: 2 comments 5 replies
-
@davidhewitt and others, do you guys have an opinion on this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
The cfg flags are set according to the interpreter which |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have been coding Rust for around two years - I'd also written some procedural macros and a few crates - so I understand how macros work, etc. Thank you for building
pyo3
.From this, I understand how
pyo3
sets certain--cfg
/--check-cfg
flags torustc
.If we look at this piece of code copied from the documentation:
The following points can be made:
pyo3
does not control the attribute macro#[cfg(...)]
, it is controlled byrustc
.pyo3
does not control the client's codes, e.g. the functionfunction_only_supported_on_python_3_7_and_up()
.pyo3
has is the flagPy_3_7
, which in the client'sbuild.rs
script will be passed torustc
and set as a flag.pyo3
can possibly get the--cfg
flag (by interrogatingrustc
or through environment variables) - knowing ifPy_3_7
is set;pyo3
still doesn't control#[cfg(...)]
so it can't control how the functionfunction_only_supported_on_python_3_7_and_up()
is expanded.Hence, my question:
How did
pyo3
accomplish this?From knowing if a flag, e.g.
Py_3_7
, is set or not to conditional compilation of codes depending on whether thePython
executable is of version 3.7 and above.Thank you.
Beta Was this translation helpful? Give feedback.
All reactions