Skip to main content

pyo3/
lib.rs

1#![warn(
2    clippy::alloc_instead_of_core,
3    clippy::std_instead_of_alloc,
4    clippy::std_instead_of_core
5)]
6#![warn(missing_docs)]
7#![cfg_attr(
8    feature = "nightly",
9    feature(auto_traits, negative_impls, iter_advance_by)
10)]
11#![cfg_attr(all(feature = "nightly", Py_GIL_DISABLED), feature(try_trait_v2))]
12#![cfg_attr(docsrs, feature(doc_cfg))]
13// Deny some lints in doctests.
14// Use `#[allow(...)]` locally to override.
15#![doc(test(attr(
16    deny(
17        rust_2018_idioms,
18        unused_lifetimes,
19        rust_2021_prelude_collisions,
20        warnings
21    ),
22    allow(
23        unused_imports,  // to make imports already in the prelude explicit
24        unused_variables,
25        unused_assignments,
26        unused_extern_crates,
27        // FIXME https://github.com/rust-lang/rust/issues/121621#issuecomment-1965156376
28        unknown_lints,
29        non_local_definitions,
30    )
31)))]
32
33//! Rust bindings to the Python interpreter.
34//!
35//! PyO3 can be used to write native Python modules or run Python code and modules from Rust.
36//!
37//! See [the guide] for a detailed introduction.
38//!
39//! # PyO3's object types
40//!
41//! PyO3 has several core types that you should familiarize yourself with:
42//!
43//! ## The `Python<'py>` object, and the `'py` lifetime
44//!
45//! Holding the [global interpreter lock] (GIL) is modeled with the [`Python<'py>`](Python) token. Many
46//! Python APIs require that the GIL is held, and PyO3 uses this token as proof that these APIs
47//! can be called safely. It can be explicitly acquired and is also implicitly acquired by PyO3
48//! as it wraps Rust functions and structs into Python functions and objects.
49//!
50//! The [`Python<'py>`](Python) token's lifetime `'py` is common to many PyO3 APIs:
51//! - Types that also have the `'py` lifetime, such as the [`Bound<'py, T>`](Bound) smart pointer, are
52//!   bound to the Python GIL and rely on this to offer their functionality. These types often
53//!   have a [`.py()`](Bound::py) method to get the associated [`Python<'py>`](Python) token.
54//! - Functions which depend on the `'py` lifetime, such as [`PyList::new`](types::PyList::new),
55//!   require a [`Python<'py>`](Python) token as an input. Sometimes the token is passed implicitly by
56//!   taking a [`Bound<'py, T>`](Bound) or other type which is bound to the `'py` lifetime.
57//! - Traits which depend on the `'py` lifetime, such as [`FromPyObject<'py>`](FromPyObject), usually have
58//!   inputs or outputs which depend on the lifetime. Adding the lifetime to the trait allows
59//!   these inputs and outputs to express their binding to the GIL in the Rust type system.
60//!
61//! ## Python object smart pointers
62//!
63//! PyO3 has two core smart pointers to refer to Python objects, [`Py<T>`](Py) and its GIL-bound
64//! form [`Bound<'py, T>`](Bound) which carries the `'py` lifetime. (There is also
65//! [`Borrowed<'a, 'py, T>`](instance::Borrowed), but it is used much more rarely).
66//!
67//! The type parameter `T` in these smart pointers can be filled by:
68//!   - [`PyAny`], e.g. `Py<PyAny>` or `Bound<'py, PyAny>`, where the Python object type is not
69//!     known.
70//!   - Concrete Python types like [`PyList`](types::PyList) or [`PyTuple`](types::PyTuple).
71//!   - Rust types which are exposed to Python using the [`#[pyclass]`](macro@pyclass) macro.
72//!
73//! See the [guide][types] for an explanation of the different Python object types.
74//!
75//! ## PyErr
76//!
77//! The vast majority of operations in this library will return [`PyResult<...>`](PyResult).
78//! This is an alias for the type `Result<..., PyErr>`.
79//!
80//! A `PyErr` represents a Python exception. A `PyErr` returned to Python code will be raised as a
81//! Python exception. Errors from `PyO3` itself are also exposed as Python exceptions.
82//!
83//! # Feature flags
84//!
85//! PyO3 uses [feature flags] to enable you to opt-in to additional functionality. For a detailed
86//! description, see the [Features chapter of the guide].
87//!
88//! ## Default feature flags
89//!
90//! The following features are turned on by default:
91//! - `macros`: Enables various macros, including all the attribute macros.
92//!
93//! ## Optional feature flags
94//!
95//! The following features customize PyO3's behavior:
96//!
97//! - `abi3`: Restricts PyO3's API to a subset of the full Python API which is guaranteed by
98//! [PEP 384] to be forward-compatible with future Python versions.
99//! - `auto-initialize`: Changes [`Python::attach`] to automatically initialize the Python
100//! interpreter if needed.
101//! - `multiple-pymethods`: Enables the use of multiple [`#[pymethods]`](macro@crate::pymethods)
102//! blocks per [`#[pyclass]`](macro@crate::pyclass). This adds a dependency on the [inventory]
103//! crate, which is not supported on all platforms.
104//!
105//! The following features enable interactions with other crates in the Rust ecosystem:
106//! - [`anyhow`]: Enables a conversion from [anyhow]’s [`Error`][anyhow_error] type to [`PyErr`].
107//! - [`chrono`]: Enables a conversion from [chrono]'s structures to the equivalent Python ones.
108//! - [`chrono-tz`]: Enables a conversion from [chrono-tz]'s `Tz` enum. Requires Python 3.9+.
109//! - [`either`]: Enables conversions between Python objects and [either]'s [`Either`] type.
110//! - [`eyre`]: Enables a conversion from [eyre]’s [`Report`] type to [`PyErr`].
111//! - [`hashbrown`]: Enables conversions between Python objects and [hashbrown]'s [`HashMap`] and
112//! [`HashSet`] types.
113//! - [`indexmap`][indexmap_feature]: Enables conversions between Python dictionary and [indexmap]'s [`IndexMap`].
114//! - [`num-bigint`]: Enables conversions between Python objects and [num-bigint]'s [`BigInt`] and
115//! [`BigUint`] types.
116//! - [`num-complex`]: Enables conversions between Python objects and [num-complex]'s [`Complex`]
117//!  type.
118//! - [`num-rational`]: Enables conversions between Python's fractions.Fraction and [num-rational]'s types
119//! - [`ordered-float`]: Enables conversions between Python's float and [ordered-float]'s types
120//! - [`rust_decimal`]: Enables conversions between Python's decimal.Decimal and [rust_decimal]'s
121//! [`Decimal`] type.
122//! - [`serde`]: Allows implementing [serde]'s [`Serialize`] and [`Deserialize`] traits for
123//! [`Py`]`<T>` for all `T` that implement [`Serialize`] and [`Deserialize`].
124//! - [`smallvec`][smallvec]: Enables conversions between Python list and [smallvec]'s [`SmallVec`].
125//!
126//! ## Unstable features
127//!
128//! - `nightly`: Uses  `#![feature(auto_traits, negative_impls)]` to define [`Ungil`] as an auto trait.
129//
130//! ## `rustc` environment flags
131//! - `Py_3_9`, `Py_3_10`, `Py_3_11`, `Py_3_12`, `Py_3_13`, `Py_3_14`: Marks code that is
132//!    only enabled when compiling for a given minimum Python version.
133//! - `Py_LIMITED_API`: Marks code enabled when the `abi3` feature flag is enabled.
134//! - `Py_GIL_DISABLED`: Marks code that runs only in the free-threaded build of CPython.
135//! - `PyPy` - Marks code enabled when compiling for PyPy.
136//! - `GraalPy` - Marks code enabled when compiling for GraalPy.
137//!
138//! Additionally, you can query for the values `Py_DEBUG`, `Py_REF_DEBUG`,
139//! `Py_TRACE_REFS`, and `COUNT_ALLOCS` from `py_sys_config` to query for the
140//! corresponding C build-time defines. For example, to conditionally define
141//! debug code using `Py_DEBUG`, you could do:
142//!
143//! ```rust,ignore
144//! #[cfg(py_sys_config = "Py_DEBUG")]
145//! println!("only runs if python was compiled with Py_DEBUG")
146//! ```
147//! To use these attributes, add [`pyo3-build-config`] as a build dependency in
148//! your `Cargo.toml` and call `pyo3_build_config::use_pyo3_cfgs()` in a
149//! `build.rs` file.
150//!
151//! # Minimum supported Rust and Python versions
152//!
153//! Requires Rust 1.63 or greater.
154//!
155//! PyO3 supports the following Python distributions:
156//!   - CPython 3.9 or greater
157//!   - PyPy 7.3 (Python 3.11+)
158//!   - GraalPy 24.0 or greater (Python 3.10+)
159//!
160//! # Example: Building a native Python module
161//!
162//! PyO3 can be used to generate a native Python module. The easiest way to try this out for the
163//! first time is to use [`maturin`]. `maturin` is a tool for building and publishing Rust-based
164//! Python packages with minimal configuration. The following steps set up some files for an example
165//! Python module, install `maturin`, and then show how to build and import the Python module.
166//!
167//! First, create a new folder (let's call it `string_sum`) containing the following two files:
168//!
169//! **`Cargo.toml`**
170//!
171//! ```toml
172//! [package]
173//! name = "string-sum"
174//! version = "0.1.0"
175//! edition = "2021"
176//!
177//! [lib]
178//! name = "string_sum"
179//! # "cdylib" is necessary to produce a shared library for Python to import from.
180//! #
181//! # Downstream Rust code (including code in `bin/`, `examples/`, and `tests/`) will not be able
182//! # to `use string_sum;` unless the "rlib" or "lib" crate type is also included, e.g.:
183//! # crate-type = ["cdylib", "rlib"]
184//! crate-type = ["cdylib"]
185//!
186//! [dependencies]
187#![doc = concat!("pyo3 = \"", env!("CARGO_PKG_VERSION"),  "\"")]
188//! ```
189//!
190//! **`src/lib.rs`**
191//! ```rust,no_run
192//! use pyo3::prelude::*;
193//!
194//! /// Formats the sum of two numbers as string.
195//! #[pyfunction]
196//! fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
197//!     Ok((a + b).to_string())
198//! }
199//!
200//! /// A Python module implemented in Rust.
201//! #[pymodule]
202//! fn string_sum(m: &Bound<'_, PyModule>) -> PyResult<()> {
203//!     m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
204//!
205//!     Ok(())
206//! }
207//! ```
208//!
209//! With those two files in place, now `maturin` needs to be installed. This can be done using
210//! Python's package manager `pip`. First, load up a new Python `virtualenv`, and install `maturin`
211//! into it:
212//! ```bash
213//! $ cd string_sum
214//! $ python -m venv .env
215//! $ source .env/bin/activate
216//! $ pip install maturin
217//! ```
218//!
219//! Now build and execute the module:
220//! ```bash
221//! $ maturin develop
222//! # lots of progress output as maturin runs the compilation...
223//! $ python
224//! >>> import string_sum
225//! >>> string_sum.sum_as_string(5, 20)
226//! '25'
227//! ```
228//!
229//! As well as with `maturin`, it is possible to build using [setuptools-rust] or
230//! [manually][manual_builds]. Both offer more flexibility than `maturin` but require further
231//! configuration.
232//!
233//! # Example: Using Python from Rust
234//!
235//! To embed Python into a Rust binary, you need to ensure that your Python installation contains a
236//! shared library. The following steps demonstrate how to ensure this (for Ubuntu), and then give
237//! some example code which runs an embedded Python interpreter.
238//!
239//! To install the Python shared library on Ubuntu:
240//! ```bash
241//! sudo apt install python3-dev
242//! ```
243//!
244//! Start a new project with `cargo new` and add  `pyo3` to the `Cargo.toml` like this:
245//! ```toml
246//! [dependencies.pyo3]
247#![doc = concat!("version = \"", env!("CARGO_PKG_VERSION"),  "\"")]
248//! # this is necessary to automatically initialize the Python interpreter
249//! features = ["auto-initialize"]
250//! ```
251//!
252//! Example program displaying the value of `sys.version` and the current user name:
253//! ```rust
254//! use pyo3::prelude::*;
255//! use pyo3::types::IntoPyDict;
256//!
257//! fn main() -> PyResult<()> {
258//!     Python::attach(|py| {
259//!         let sys = py.import("sys")?;
260//!         let version: String = sys.getattr("version")?.extract()?;
261//!
262//!         let locals = [("os", py.import("os")?)].into_py_dict(py)?;
263//!         let code = c"os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
264//!         let user: String = py.eval(code, None, Some(&locals))?.extract()?;
265//!
266//!         println!("Hello {}, I'm Python {}", user, version);
267//!         Ok(())
268//!     })
269//! }
270//! ```
271//!
272//! The guide has [a section][calling_rust] with lots of examples about this topic.
273//!
274//! # Other Examples
275//!
276//! The PyO3 [README](https://github.com/PyO3/pyo3#readme) contains quick-start examples for both
277//! using [Rust from Python] and [Python from Rust].
278//!
279//! The PyO3 repository's [examples subdirectory]
280//! contains some basic packages to demonstrate usage of PyO3.
281//!
282//! There are many projects using PyO3 - see a list of some at
283//! <https://github.com/PyO3/pyo3#examples>.
284//!
285//! [anyhow]: https://docs.rs/anyhow/ "A trait object based error system for easy idiomatic error handling in Rust applications."
286//! [anyhow_error]: https://docs.rs/anyhow/latest/anyhow/struct.Error.html "Anyhows `Error` type, a wrapper around a dynamic error type"
287//! [`anyhow`]: ./anyhow/index.html "Documentation about the `anyhow` feature."
288//! [inventory]: https://docs.rs/inventory
289//! [`HashMap`]: https://docs.rs/hashbrown/latest/hashbrown/struct.HashMap.html
290//! [`HashSet`]: https://docs.rs/hashbrown/latest/hashbrown/struct.HashSet.html
291//! [`SmallVec`]: https://docs.rs/smallvec/latest/smallvec/struct.SmallVec.html
292//! [`Uuid`]: https://docs.rs/uuid/latest/uuid/struct.Uuid.html
293//! [`IndexMap`]: https://docs.rs/indexmap/latest/indexmap/map/struct.IndexMap.html
294//! [`BigInt`]: https://docs.rs/num-bigint/latest/num_bigint/struct.BigInt.html
295//! [`BigUint`]: https://docs.rs/num-bigint/latest/num_bigint/struct.BigUint.html
296//! [`Complex`]: https://docs.rs/num-complex/latest/num_complex/struct.Complex.html
297//! [`Deserialize`]: https://docs.rs/serde/latest/serde/trait.Deserialize.html
298//! [`Serialize`]: https://docs.rs/serde/latest/serde/trait.Serialize.html
299//! [chrono]: https://docs.rs/chrono/ "Date and Time for Rust."
300//! [chrono-tz]: https://docs.rs/chrono-tz/ "TimeZone implementations for chrono from the IANA database."
301//! [`chrono`]: ./chrono/index.html "Documentation about the `chrono` feature."
302//! [`chrono-tz`]: ./chrono-tz/index.html "Documentation about the `chrono-tz` feature."
303//! [either]: https://docs.rs/either/ "A type that represents one of two alternatives."
304//! [`either`]: ./either/index.html "Documentation about the `either` feature."
305//! [`Either`]: https://docs.rs/either/latest/either/enum.Either.html
306//! [eyre]: https://docs.rs/eyre/ "A library for easy idiomatic error handling and reporting in Rust applications."
307//! [`Report`]: https://docs.rs/eyre/latest/eyre/struct.Report.html
308//! [`eyre`]: ./eyre/index.html "Documentation about the `eyre` feature."
309//! [`hashbrown`]: ./hashbrown/index.html "Documentation about the `hashbrown` feature."
310//! [indexmap_feature]: ./indexmap/index.html "Documentation about the `indexmap` feature."
311//! [`maturin`]: https://github.com/PyO3/maturin "Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as python packages"
312//! [`num-bigint`]: ./num_bigint/index.html "Documentation about the `num-bigint` feature."
313//! [`num-complex`]: ./num_complex/index.html "Documentation about the `num-complex` feature."
314//! [`num-rational`]: ./num_rational/index.html "Documentation about the `num-rational` feature."
315//! [`ordered-float`]: ./ordered_float/index.html "Documentation about the `ordered-float` feature."
316//! [`pyo3-build-config`]: https://docs.rs/pyo3-build-config
317//! [rust_decimal]: https://docs.rs/rust_decimal
318//! [`rust_decimal`]: ./rust_decimal/index.html "Documentation about the `rust_decimal` feature."
319//! [`Decimal`]: https://docs.rs/rust_decimal/latest/rust_decimal/struct.Decimal.html
320//! [`serde`]: <./serde/index.html> "Documentation about the `serde` feature."
321#![doc = concat!("[calling_rust]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/python-from-rust.html \"Calling Python from Rust - PyO3 user guide\"")]
322//! [examples subdirectory]: https://github.com/PyO3/pyo3/tree/main/examples
323//! [feature flags]: https://doc.rust-lang.org/cargo/reference/features.html "Features - The Cargo Book"
324//! [global interpreter lock]: https://docs.python.org/3/glossary.html#term-global-interpreter-lock
325//! [hashbrown]: https://docs.rs/hashbrown
326//! [smallvec]: https://docs.rs/smallvec
327//! [uuid]: https://docs.rs/uuid
328//! [indexmap]: https://docs.rs/indexmap
329#![doc = concat!("[manual_builds]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/building-and-distribution.html#manual-builds \"Manual builds - Building and Distribution - PyO3 user guide\"")]
330//! [num-bigint]: https://docs.rs/num-bigint
331//! [num-complex]: https://docs.rs/num-complex
332//! [num-rational]: https://docs.rs/num-rational
333//! [ordered-float]: https://docs.rs/ordered-float
334//! [serde]: https://docs.rs/serde
335//! [setuptools-rust]: https://github.com/PyO3/setuptools-rust "Setuptools plugin for Rust extensions"
336//! [the guide]: https://pyo3.rs "PyO3 user guide"
337#![doc = concat!("[types]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/types.html \"GIL lifetimes, mutability and Python object types\"")]
338//! [PEP 384]: https://www.python.org/dev/peps/pep-0384 "PEP 384 -- Defining a Stable ABI"
339//! [Python from Rust]: https://github.com/PyO3/pyo3#using-python-from-rust
340//! [Rust from Python]: https://github.com/PyO3/pyo3#using-rust-from-python
341#![doc = concat!("[Features chapter of the guide]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/features.html#features-reference \"Features Reference - PyO3 user guide\"")]
342//! [`Ungil`]: crate::marker::Ungil
343
344extern crate alloc;
345
346pub use crate::class::*;
347pub use crate::conversion::{FromPyObject, IntoPyObject, IntoPyObjectExt};
348pub use crate::err::{CastError, CastIntoError, PyErr, PyErrArguments, PyResult, ToPyErr};
349pub use crate::instance::{Borrowed, Bound, BoundObject, Py};
350#[cfg(not(any(PyPy, GraalPy)))]
351pub use crate::interpreter_lifecycle::with_embedded_python_interpreter;
352pub use crate::marker::Python;
353pub use crate::pycell::{PyRef, PyRefMut};
354pub use crate::pyclass::{PyClass, PyClassGuard, PyClassGuardMut};
355pub use crate::pyclass_init::PyClassInitializer;
356pub use crate::type_object::{PyTypeCheck, PyTypeInfo};
357pub use crate::types::PyAny;
358pub use crate::version::PythonVersionInfo;
359
360pub(crate) mod ffi_ptr_ext;
361pub(crate) mod py_result_ext;
362pub(crate) mod sealed;
363
364mod platform;
365
366/// Old module which contained some implementation details of the `#[pyproto]` module.
367///
368/// Prefer using the same content from `pyo3::pyclass`, e.g. `use pyo3::pyclass::CompareOp` instead
369/// of `use pyo3::class::basic::CompareOp`.
370///
371/// For compatibility reasons this has not yet been removed, however will be done so
372/// once <https://github.com/rust-lang/rust/issues/30827> is resolved.
373pub mod class {
374    pub use self::gc::{PyTraverseError, PyVisit};
375
376    /// Old module which contained some implementation details of the `#[pyproto]` module.
377    ///
378    /// Prefer using the same content from `pyo3::pyclass`, e.g. `use pyo3::pyclass::CompareOp` instead
379    /// of `use pyo3::class::basic::CompareOp`.
380    ///
381    /// For compatibility reasons this has not yet been removed, however will be done so
382    /// once <https://github.com/rust-lang/rust/issues/30827> is resolved.
383    pub mod basic {
384        pub use crate::pyclass::CompareOp;
385    }
386
387    /// Old module which contained some implementation details of the `#[pyproto]` module.
388    ///
389    /// Prefer using the same content from `pyo3::pyclass`, e.g. `use pyo3::pyclass::PyTraverseError` instead
390    /// of `use pyo3::class::gc::PyTraverseError`.
391    ///
392    /// For compatibility reasons this has not yet been removed, however will be done so
393    /// once <https://github.com/rust-lang/rust/issues/30827> is resolved.
394    pub mod gc {
395        pub use crate::pyclass::{PyTraverseError, PyVisit};
396    }
397}
398
399#[cfg(all(feature = "macros", feature = "multiple-pymethods"))]
400#[doc(hidden)]
401pub use inventory; // Re-exported for `#[pyclass]` and `#[pymethods]` with `multiple-pymethods`.
402
403/// Tests and helpers which reside inside PyO3's main library. Declared first so that macros
404/// are available in unit tests.
405#[cfg(test)]
406mod test_utils;
407#[cfg(test)]
408mod tests;
409
410#[macro_use]
411mod internal;
412#[macro_use]
413mod internal_tricks;
414
415// Macro dependencies, also contains macros exported for use across the codebase and
416// in expanded macros.
417#[doc(hidden)]
418pub mod impl_;
419
420pub mod buffer;
421pub mod call;
422pub mod conversion;
423mod conversions;
424#[cfg(feature = "experimental-async")]
425pub mod coroutine;
426mod err;
427pub mod exceptions;
428pub mod ffi;
429pub(crate) mod fmt;
430mod instance;
431mod interpreter_lifecycle;
432pub mod marker;
433pub mod marshal;
434#[macro_use]
435pub mod sync;
436pub(crate) mod byteswriter;
437pub mod panic;
438pub mod pybacked;
439pub mod pycell;
440pub mod pyclass;
441pub mod pyclass_init;
442
443pub mod type_object;
444pub mod types;
445mod version;
446
447#[allow(
448    unused_imports,
449    reason = "with no features enabled this module has no public exports"
450)]
451pub use crate::conversions::*;
452
453#[cfg(feature = "macros")]
454pub use pyo3_macros::{
455    pyfunction, pymethods, pymodule, FromPyObject, IntoPyObject, IntoPyObjectRef,
456};
457
458/// A proc macro used to expose Rust structs and fieldless enums as Python objects.
459///
460#[doc = include_str!("../guide/pyclass-parameters.md")]
461///
462/// For more on creating Python classes,
463/// see the [class section of the guide][1].
464///
465#[doc = concat!("[1]: https://pyo3.rs/v", env!("CARGO_PKG_VERSION"), "/class.html")]
466#[cfg(feature = "macros")]
467pub use pyo3_macros::pyclass;
468
469#[cfg(feature = "macros")]
470#[macro_use]
471mod macros;
472
473#[cfg(feature = "experimental-inspect")]
474pub mod inspect;
475
476// Putting the declaration of prelude at the end seems to help encourage rustc and rustdoc to prefer using
477// other paths to the same items. (e.g. `pyo3::types::PyAnyMethods` instead of `pyo3::prelude::PyAnyMethods`).
478pub mod prelude;
479
480/// Test readme and user guide
481#[cfg(doctest)]
482pub mod doc_test {
483    macro_rules! doctests {
484        ($($path:expr => $mod:ident),* $(,)?) => {
485            $(
486                #[doc = include_str!(concat!("../", $path))]
487                mod $mod{}
488            )*
489        };
490    }
491
492    doctests! {
493        "README.md" => readme_md,
494        "guide/src/advanced.md" => guide_advanced_md,
495        "guide/src/async-await.md" => guide_async_await_md,
496        "guide/src/building-and-distribution.md" => guide_building_and_distribution_md,
497        "guide/src/building-and-distribution/multiple-python-versions.md" => guide_bnd_multiple_python_versions_md,
498        "guide/src/class.md" => guide_class_md,
499        "guide/src/class/call.md" => guide_class_call,
500        "guide/src/class/object.md" => guide_class_object,
501        "guide/src/class/numeric.md" => guide_class_numeric,
502        "guide/src/class/protocols.md" => guide_class_protocols_md,
503        "guide/src/class/thread-safety.md" => guide_class_thread_safety_md,
504        "guide/src/conversions.md" => guide_conversions_md,
505        "guide/src/conversions/tables.md" => guide_conversions_tables_md,
506        "guide/src/conversions/traits.md" => guide_conversions_traits_md,
507        "guide/src/debugging.md" => guide_debugging_md,
508
509        // deliberate choice not to test guide/ecosystem because those pages depend on external
510        // crates such as pyo3_asyncio.
511
512        "guide/src/exception.md" => guide_exception_md,
513        "guide/src/faq.md" => guide_faq_md,
514        "guide/src/features.md" => guide_features_md,
515        "guide/src/free-threading.md" => guide_free_threading_md,
516        "guide/src/function.md" => guide_function_md,
517        "guide/src/function/error-handling.md" => guide_function_error_handling_md,
518        "guide/src/function/signature.md" => guide_function_signature_md,
519        "guide/src/migration.md" => guide_migration_md,
520        "guide/src/module.md" => guide_module_md,
521        "guide/src/parallelism.md" => guide_parallelism_md,
522        "guide/src/performance.md" => guide_performance_md,
523        "guide/src/python-from-rust.md" => guide_python_from_rust_md,
524        "guide/src/python-from-rust/calling-existing-code.md" => guide_pfr_calling_existing_code_md,
525        "guide/src/python-from-rust/function-calls.md" => guide_pfr_function_calls_md,
526        "guide/src/python-typing-hints.md" => guide_python_typing_hints_md,
527        "guide/src/rust-from-python.md" => guide_rust_from_python_md,
528        "guide/src/trait-bounds.md" => guide_trait_bounds_md,
529        "guide/src/types.md" => guide_types_md,
530    }
531}