Skip to main content

rustpython_vm/
lib.rs

1//! This crate contains most of the python logic.
2//!
3//! - Interpreter
4//! - Import mechanics
5//! - Base objects
6//!
7//! Some stdlib modules are implemented here, but most of them are in the `rustpython-stdlib` module. The
8
9#![deny(clippy::disallowed_methods, clippy::disallowed_types)]
10#![allow(
11    clippy::module_inception,
12    reason = "
13 to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
14 how `mod` works, but we want this sometimes for pymodule declarations"
15)]
16#![allow(
17    clippy::upper_case_acronyms,
18    reason = "
19we want to mirror python naming conventions when defining python structs, so that does mean
20uppercase acronyms, e.g. TextIOWrapper instead of TextIoWrapper"
21)]
22#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
23#![doc(html_root_url = "https://docs.rs/rustpython-vm/")]
24
25#[cfg(feature = "flame-it")]
26#[macro_use]
27extern crate flamer;
28
29#[macro_use]
30extern crate bitflags;
31#[macro_use]
32extern crate log;
33// extern crate env_logger;
34extern crate alloc;
35
36#[macro_use]
37extern crate rustpython_derive;
38
39extern crate self as rustpython_vm;
40
41pub use rustpython_derive::*;
42
43//extern crate eval; use eval::eval::*;
44// use py_code_object::{Function, NativeType, PyCodeObject};
45
46// This is above everything else so that the defined macros are available everywhere
47#[macro_use]
48pub(crate) mod macros;
49
50mod anystr;
51pub mod buffer;
52pub mod builtins;
53pub mod byte;
54mod bytes_inner;
55pub mod cformat;
56pub mod class;
57mod codecs;
58pub mod compiler;
59pub mod convert;
60mod coroutine;
61pub mod datastack;
62mod dict_inner;
63
64#[cfg(feature = "rustpython-compiler")]
65pub mod eval;
66
67mod exception_group;
68pub mod exceptions;
69pub mod format;
70pub mod frame;
71pub mod function;
72pub mod getpath;
73pub mod import;
74mod intern;
75pub mod iter;
76pub mod object;
77
78#[cfg(feature = "host_env")]
79#[cfg(feature = "opcode-histogram")]
80pub mod opcode_histogram;
81pub mod ospath;
82#[cfg(feature = "host_env")]
83mod ospath_fd;
84
85pub mod prelude;
86pub mod protocol;
87pub mod py_io;
88
89#[cfg(feature = "serde")]
90pub mod py_serde;
91
92pub mod gc_state;
93pub use rustpython_host_env::readline;
94pub mod recursion;
95pub mod scope;
96pub mod sequence;
97pub mod signal;
98pub mod sliceable;
99pub mod sorting;
100pub mod stdlib;
101pub mod suggestion;
102pub mod types;
103pub mod utils;
104pub mod version;
105pub mod vm;
106pub mod warn;
107
108#[cfg(windows)]
109pub mod windows;
110
111pub use self::convert::{TryFromBorrowedObject, TryFromObject};
112pub use self::object::{
113    AsObject, Py, PyAtomicRef, PyExact, PyObject, PyObjectCell, PyObjectRef, PyPayload, PyRef,
114    PyRefExact, PyResult, PyStackRef, PyWeakRef,
115};
116pub use self::vm::runtime;
117pub use self::vm::{
118    Context, InterpFeatureFlags, Interpreter, InterpreterBuilder, InterpreterConfig,
119    InterpreterGil, InterpreterInfo, InterpreterWhence, MAIN_INTERPRETER_ID, Settings,
120    VirtualMachine,
121};
122
123pub use rustpython_common as common;
124pub use rustpython_compiler_core::{bytecode, frozen};
125pub use rustpython_host_env as host_env;
126pub use rustpython_literal as literal;
127
128#[doc(hidden)]
129pub mod __exports {
130    pub use paste;
131}