Skip to content

Commit

Permalink
Document all of the config attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Oct 23, 2024
1 parent 722571c commit 7257e24
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pyo3-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,25 @@
//! PyO3 uses `rustc`'s `--cfg` flags to enable or disable code used for different Python versions.
//! If you want to do this for your own crate, you can do so with the [`pyo3-build-config`] crate.
//!
//! - `Py_3_7`, `Py_3_8`, `Py_3_9`, `Py_3_10`: Marks code that is only enabled when
//! compiling for a given minimum Python version.
//! - `Py_3_7`, `Py_3_8`, `Py_3_9`, `Py_3_10`, `Py_3_11`, `Py_3_12`, `Py_3_13`: Marks code that is
//! only enabled when compiling for a given minimum Python version.
//! - `Py_LIMITED_API`: Marks code enabled when the `abi3` feature flag is enabled.
//! - `Py_GIL_DISABLED`: Marks code that runs only in the free-threaded build of CPython.
//! - `PyPy` - Marks code enabled when compiling for PyPy.
//! - `GraalPy` - Marks code enabled when compiling for GraalPy.
//!
//! Add [`pyo3-build-config`] as a build dependency in your `Cargo.toml`:
//! Additionally, you can query for the values `Py_DEBUG`, `Py_REF_DEBUG`,
//! `Py_TRACE_REFS`, and `COUNT_ALLOCS` from `py_sys_config` to query for the
//! corresponding C build-time defines. For example, to conditionally define
//! debug code using `Py_DEBUG`, you could do:
//!
//! ```rust
//! #[cfg(py_sys_config = "Py_DEBUG")]
//! // code that only runs if python was compiled with Py_DEBUG
//! ```
//!
//! To use these attributes, add [`pyo3-build-config`] as a build dependency in
//! your `Cargo.toml`:
//!
//! ```toml
//! [build-dependency]
Expand Down

0 comments on commit 7257e24

Please sign in to comment.