[package] name = "pyo3" version = "0.29.2" description = "Bindings to Python interpreter" authors = ["PyO3 Project and Contributors "] readme = "README.md" keywords = ["pyo3", "python", "cpython", "ffi"] homepage = "https://github.com/pyo3/pyo3" repository = "https://github.com/pyo3/pyo3" documentation = "https://docs.rs/crate/pyo3/" categories = ["api-bindings", "development-tools::ffi"] license = "MIT OR Apache-2.0" exclude = [ "/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/noxfile.py", "/.github", "/tests/test_compile_error.rs", "/tests/ui", ] edition = "2021" # This allows PyO3 to forward build-config from `pyo3-ffi` to avoid downstream crates # needing to depend on `pyo3-ffi` directly to use `pyo3-build-config` functionality. # # See also https://github.com/rust-lang/cargo/issues/3544 and # https://github.com/rust-lang/cargo/pull/16436 which may allow this to be # reverted in the future. links = "pyo3-python" rust-version.workspace = true [dependencies] libc = "0.2.62" once_cell = "1.21" # ffi bindings to the python interpreter, split into a separate crate so they can be used independently pyo3-ffi = { path = "pyo3-ffi", version = "=0.29.2" } # support crate for macros feature pyo3-macros = { path = "pyo3-macros", version = "=0.29.2", optional = true } # support crate for multiple-pymethods feature inventory = { version = "0.3.5", optional = true } # crate integrations that can be added using the eponymous features anyhow = { version = "1.0.1", optional = true } bigdecimal = { version = "0.4.7", optional = true } bytes = { version = "1.10", optional = true } chrono = { version = "0.4.25", default-features = false, optional = true } chrono-tz = { version = ">= 0.10, < 0.11", default-features = false, optional = true } either = { version = "1.9", optional = true } eyre = { version = ">= 0.6.8, < 0.7", optional = true } hashbrown = { version = ">= 0.15.0, < 0.18", optional = true, default-features = false, features = [ "default-hasher", ] } indexmap = { version = ">= 2.5.0, < 3", optional = true } jiff-02 = { package = "jiff", version = "0.2", optional = true } num-bigint = { version = "0.4.4", optional = true } num-complex = { version = ">= 0.4.6, < 0.5", optional = true } num-rational = { version = "0.4.1", optional = true } num-traits = { version = "0.2.16", optional = true } ordered-float = { version = "5.0.0", default-features = false, optional = true } rust_decimal = { version = "1.15", default-features = false, optional = true } time = { version = "0.3.38", default-features = false, optional = true } serde = { version = "1.0", optional = true } smallvec = { version = "1.0", optional = true } uuid = { version = "1.12.0", optional = true } lock_api = { version = "0.4", optional = true } parking_lot = { version = "0.12", optional = true } iana-time-zone = { version = "0.1", optional = true, features = ["fallback"]} [target.'cfg(not(target_has_atomic = "64"))'.dependencies] portable-atomic = "1.0" [dev-dependencies] assert_approx_eq = "1.1.0" chrono = "0.4.25" chrono-tz = ">= 0.10, < 0.11" proptest = { version = "1.0", default-features = false, features = ["std"] } send_wrapper = "0.6" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.61" rayon = "1.6.1" futures = "0.3.28" tempfile = "3.12.0" static_assertions = "1.1.0" uuid = { version = "1.10.0", features = ["v4"] } parking_lot = { version = "0.12.3", features = ["arc_lock"] } ui_test = "0.30.4" regex = "1.12.3" [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] ctrlc = "3.5.2" [build-dependencies] pyo3-build-config = { path = "pyo3-build-config", version = "=0.29.2" } [features] default = ["macros"] # Enables support for `async fn` for `#[pyfunction]` and `#[pymethods]`. experimental-async = ["macros", "pyo3-macros/experimental-async"] # Enables pyo3::inspect module and additional type information on FromPyObject # and IntoPy traits experimental-inspect = ["pyo3-macros/experimental-inspect"] # Enables macros: #[pyclass], #[pymodule], #[pyfunction] etc. macros = ["pyo3-macros"] # Enables multiple #[pymethods] per #[pyclass] multiple-pymethods = ["inventory", "pyo3-macros/multiple-pymethods"] # Deprecated: use the `PYO3_BUILD_EXTENSION_MODULE` environment variable when # building a Python extension module (set automatically by `setuptools-rust` and # `maturin`). extension-module = ["pyo3-ffi/extension-module"] # Use the Python limited API. See https://www.python.org/dev/peps/pep-0384/ for more. abi3 = ["pyo3-ffi/abi3"] # With abi3, we can manually set the minimum Python version. abi3-py38 = ["abi3-py39", "pyo3-ffi/abi3-py38"] abi3-py39 = ["abi3-py310", "pyo3-ffi/abi3-py39"] abi3-py310 = ["abi3-py311", "pyo3-ffi/abi3-py310"] abi3-py311 = ["abi3-py312", "pyo3-ffi/abi3-py311"] abi3-py312 = ["abi3-py313", "pyo3-ffi/abi3-py312"] abi3-py313 = ["abi3-py314", "pyo3-ffi/abi3-py313"] abi3-py314 = ["abi3-py315", "pyo3-ffi/abi3-py314"] abi3-py315 = ["abi3", "pyo3-ffi/abi3-py315"] abi3t = ["pyo3-ffi/abi3t"] # With abi3t, we can manually set the minimum Python version. abi3t-py315 = ["abi3t", "pyo3-ffi/abi3t-py315"] # deprecated: no longer needed, raw-dylib is used instead generate-import-lib = ["pyo3-ffi/generate-import-lib"] # Changes `Python::attach` to automatically initialize the Python interpreter if needed. auto-initialize = [] # Enables `Clone`ing references to Python objects `Py` which panics if the # thread is not attached to the Python interpreter. py-clone = [] # Adds `OnceExt` and `MutexExt` implementations to the `parking_lot` types parking_lot = ["dep:parking_lot", "lock_api"] arc_lock = ["lock_api", "lock_api/arc_lock", "parking_lot?/arc_lock"] num-bigint = ["dep:num-bigint", "dep:num-traits"] bigdecimal = ["dep:bigdecimal", "num-bigint"] chrono-local = ["chrono/clock", "dep:iana-time-zone"] # Optimizes PyObject to Vec conversion and so on. nightly = [] # Activates all additional features # This is mostly intended for testing purposes - activating *all* of these isn't particularly useful. full = [ "macros", # "multiple-pymethods", # Not supported by wasm "anyhow", "arc_lock", "bigdecimal", "bytes", "chrono", "chrono-local", "chrono-tz", "either", "experimental-async", "experimental-inspect", "eyre", "hashbrown", "indexmap", "jiff-02", "lock_api", "num-bigint", "num-complex", "num-rational", "ordered-float", "parking_lot", "py-clone", "rust_decimal", "serde", "smallvec", "time", "uuid", ] [workspace] members = [ "pyo3-ffi", "pyo3-build-config", "pyo3-macros", "pyo3-macros-backend", "pyo3-introspection", "tests/ui/base", "pytests", "examples", ] package.rust-version = "1.83" [package.metadata.docs.rs] no-default-features = true features = ["full"] rustdoc-args = ["--cfg", "docsrs"] [workspace.lints.clippy] checked_conversions = "warn" dbg_macro = "warn" explicit_into_iter_loop = "warn" explicit_iter_loop = "warn" filter_map_next = "warn" flat_map_option = "warn" let_unit_value = "warn" manual_assert = "warn" manual_ok_or = "warn" todo = "warn" undocumented_unsafe_blocks = "warn" unnecessary_wraps = "warn" useless_transmute = "warn" used_underscore_binding = "warn" [workspace.lints.rust] elided_lifetimes_in_paths = "warn" invalid_doc_attributes = "warn" rust_2018_idioms = { level = "warn", priority = -1 } rust_2021_prelude_collisions = "warn" unused_lifetimes = "warn" unsafe_op_in_unsafe_fn = "warn" [workspace.lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ 'cfg(pyo3_disable_reference_pool)', 'cfg(pyo3_leak_on_drop_without_reference_pool)', 'cfg(pyo3_use_raw_dylib)', # this horrible hard-coded list should be kept in sync with the list of possible # cfgs in pyo3-ffi/src/impl_/macros.rs # # for library names outside of this set we don't support raw-dylib and require a # proper import library # # maybe in the future this list will not be necessary, see # internals.rust-lang.org/t/support-renames-with-link-name-kind-raw-dylib/24415 'cfg(pyo3_dll, values("python3", "python3_d", "python3t", "python3t_d", "python38", "python38_d", "python39", "python39_d", "python310", "python310_d", "python311", "python311_d", "python312", "python312_d", "python313", "python313_d", "python313t", "python313t_d", "python314", "python314_d", "python314t", "python314t_d", "python315", "python315_d", "python315t", "python315t_d", "python316", "python316_d", "python316t", "python316t_d", "libpypy3.11-c"))', ] [workspace.lints.rustdoc] broken_intra_doc_links = "warn" bare_urls = "warn" [lints] workspace = true # Many tests are only relevant on certain feature combinations; # CI is marginally more efficient if `required-feature` is specified to avoid # building and launching empty test suites. [[test]] name = "test_anyhow" required-features = ["anyhow"] [[test]] name = "test_append_to_inittab" required-features = ["macros"] [[test]] name = "test_arithmetics" required-features = ["macros"] [[test]] name = "test_buffer" required-features = ["macros"] [[test]] name = "test_buffer_protocol" required-features = ["macros"] [[test]] name = "test_bytes" required-features = ["macros"] [[test]] name = "test_class_attributes" required-features = ["macros"] [[test]] name = "test_class_basics" required-features = ["macros"] [[test]] name = "test_class_comparisons" required-features = ["macros"] [[test]] name = "test_class_conversion" required-features = ["macros"] [[test]] name = "test_class_formatting" required-features = ["macros"] [[test]] name = "test_class_init" required-features = ["macros"] [[test]] name = "test_class_new" required-features = ["macros"] [[test]] name = "test_compile_error" required-features = ["macros"] harness = false [[test]] name = "test_coroutine" required-features = ["experimental-async"] [[test]] name = "test_declarative_module" required-features = ["macros"] [[test]] name = "test_default_impls" required-features = ["macros"] [[test]] name = "test_enum" required-features = ["macros"] [[test]] name = "test_exceptions" required-features = ["macros"] [[test]] name = "test_field_cfg" required-features = ["macros"] [[test]] name = "test_frompy_intopy_roundtrip" required-features = ["macros"] [[test]] name = "test_frompyobject" required-features = ["macros"] [[test]] name = "test_gc" required-features = ["macros"] [[test]] name = "test_getter_setter" required-features = ["macros"] [[test]] name = "test_inheritance" required-features = ["macros"] [[test]] name = "test_intopyobject" required-features = ["macros"] [[test]] name = "test_macro_docs" required-features = ["macros"] [[test]] name = "test_macros" required-features = ["macros"] [[test]] name = "test_mapping" required-features = ["macros"] [[test]] name = "test_methods" required-features = ["macros"] [[test]] name = "test_module" required-features = ["macros"] [[test]] name = "test_multiple_pymethods" required-features = ["multiple-pymethods"] [[test]] name = "test_proto_methods" required-features = ["macros"] [[test]] name = "test_pyfunction" required-features = ["macros"] [[test]] name = "test_pyself" required-features = ["macros"] [[test]] name = "test_sequence" required-features = ["macros"] [[test]] name = "test_serde" required-features = ["serde"] [[test]] name = "test_static_slots" required-features = ["macros"] [[test]] name = "test_string" required-features = ["macros"] [[test]] name = "test_super" required-features = ["macros"] [[test]] name = "test_text_signature" required-features = ["macros"] [[test]] name = "test_variable_arguments" required-features = ["macros"] [[test]] name = "test_various" required-features = ["macros"]