use {python3_sys as pyffi, std::ffi::CString};
#[derive(Clone, Debug)]
pub enum PythonRawAllocator {
Jemalloc,
Rust,
System,
}
#[derive(Clone, Debug)]
pub enum PythonRunMode {
None,
Repl,
Module { module: String },
Eval { code: String },
File { path: CString },
}
#[derive(Clone, Debug)]
pub enum TerminfoResolution {
Dynamic,
None,
Static(String),
}
#[derive(Clone, Debug)]
pub struct ExtensionModule {
pub name: CString,
pub init_func: unsafe extern "C" fn() -> *mut pyffi::PyObject,
}
#[derive(Clone, Debug)]
pub struct PythonConfig {
pub standard_io_encoding: Option<String>,
pub standard_io_errors: Option<String>,
pub opt_level: i32,
pub use_custom_importlib: bool,
pub filesystem_importer: bool,
pub sys_paths: Vec<String>,
pub bytes_warning: i32,
pub import_site: bool,
pub import_user_site: bool,
pub ignore_python_env: bool,
pub inspect: bool,
pub interactive: bool,
pub isolated: bool,
pub legacy_windows_fs_encoding: bool,
pub legacy_windows_stdio: bool,
pub write_bytecode: bool,
pub unbuffered_stdio: bool,
pub parser_debug: bool,
pub quiet: bool,
pub use_hash_seed: bool,
pub verbose: i32,
pub frozen_importlib_bytecode: &'static [u8],
pub frozen_importlib_external_bytecode: &'static [u8],
pub packed_resources: &'static [u8],
pub extra_extension_modules: Vec<ExtensionModule>,
pub argvb: bool,
pub sys_frozen: bool,
pub sys_meipass: bool,
pub raw_allocator: PythonRawAllocator,
pub terminfo_resolution: TerminfoResolution,
pub write_modules_directory_env: Option<String>,
pub run: PythonRunMode,
}
impl Default for PythonConfig {
#[allow(unused)]
fn default() -> Self {
PythonConfig {
standard_io_encoding: None,
standard_io_errors: None,
opt_level: 0,
use_custom_importlib: false,
filesystem_importer: false,
sys_paths: vec![],
bytes_warning: 0,
import_site: false,
import_user_site: false,
ignore_python_env: true,
inspect: false,
interactive: false,
isolated: false,
legacy_windows_fs_encoding: false,
legacy_windows_stdio: false,
write_bytecode: false,
unbuffered_stdio: false,
parser_debug: false,
quiet: false,
use_hash_seed: false,
verbose: 0,
frozen_importlib_bytecode: &[],
frozen_importlib_external_bytecode: &[],
packed_resources: &[],
extra_extension_modules: vec![],
argvb: false,
sys_frozen: false,
sys_meipass: false,
raw_allocator: if cfg!(windows) {
PythonRawAllocator::System
} else {
PythonRawAllocator::Jemalloc
},
terminfo_resolution: TerminfoResolution::Dynamic,
write_modules_directory_env: None,
run: PythonRunMode::None,
}
}
}