#[cfg(feature = "flame-it")]
use std::ffi::OsString;
#[derive(Debug, Clone, Default)]
pub struct Paths {
pub executable: String,
pub base_executable: String,
pub prefix: String,
pub base_prefix: String,
pub exec_prefix: String,
pub base_exec_prefix: String,
pub stdlib_dir: Option<String>,
pub module_search_paths: Vec<String>,
}
pub struct PyConfig {
pub settings: Settings,
pub paths: Paths,
}
impl PyConfig {
pub fn new(settings: Settings, paths: Paths) -> Self {
Self { settings, paths }
}
}
#[non_exhaustive]
pub struct Settings {
pub isolated: bool,
pub dev_mode: bool,
pub install_signal_handlers: bool,
pub hash_seed: Option<u32>,
pub faulthandler: bool,
pub code_debug_ranges: bool,
pub argv: Vec<String>,
pub xoptions: Vec<(String, Option<String>)>,
pub warnoptions: Vec<String>,
pub import_site: bool,
pub bytes_warning: u64,
pub warn_default_encoding: bool,
pub thread_inherit_context: bool,
pub context_aware_warnings: bool,
pub inspect: bool,
pub interactive: bool,
pub write_bytecode: bool,
pub verbose: u8,
pub quiet: bool,
pub user_site_directory: bool,
pub buffered_stdio: bool,
pub stdio_encoding: Option<String>,
pub stdio_errors: Option<String>,
pub utf8_mode: i8,
pub check_hash_pycs_mode: CheckHashPycsMode,
pub safe_path: bool,
pub int_max_str_digits: i64,
pub path_list: Vec<String>,
pub debug: u8,
pub optimize: u8,
pub ignore_environment: bool,
pub allow_external_library: bool,
#[cfg(feature = "flame-it")]
pub profile_output: Option<OsString>,
#[cfg(feature = "flame-it")]
pub profile_format: Option<String>,
}
#[derive(Debug, Default, Copy, Clone, strum_macros::Display, strum_macros::EnumString)]
#[strum(serialize_all = "lowercase")]
pub enum CheckHashPycsMode {
#[default]
Default,
Always,
Never,
}
impl Settings {
pub fn with_path(mut self, path: String) -> Self {
self.path_list.push(path);
self
}
}
impl Default for Settings {
fn default() -> Self {
Self {
debug: 0,
inspect: false,
interactive: false,
optimize: 0,
install_signal_handlers: true,
user_site_directory: true,
import_site: true,
ignore_environment: false,
verbose: 0,
quiet: false,
write_bytecode: true,
safe_path: false,
bytes_warning: 0,
xoptions: vec![],
isolated: false,
dev_mode: false,
warn_default_encoding: false,
thread_inherit_context: false,
context_aware_warnings: false,
warnoptions: vec![],
path_list: vec![],
argv: vec![],
hash_seed: None,
faulthandler: false,
code_debug_ranges: true,
buffered_stdio: true,
check_hash_pycs_mode: CheckHashPycsMode::Default,
allow_external_library: cfg!(feature = "importlib"),
stdio_encoding: None,
stdio_errors: None,
utf8_mode: -1,
int_max_str_digits: 4300,
#[cfg(feature = "flame-it")]
profile_output: None,
#[cfg(feature = "flame-it")]
profile_format: None,
}
}
}