//! Top-level names from CPython `sys.stdlib_module_names` (embedded at build time).
use std::collections::HashSet;
use std::sync::OnceLock;
fn stdlib_names() -> &'static HashSet<String> {
static SET: OnceLock<HashSet<String>> = OnceLock::new();
SET.get_or_init(|| {
include_str!("python_stdlib_modules.txt")
.lines()
.map(|l| l.trim().to_string())
.filter(|l| !l.is_empty())
.collect()
})
}
/// True if the first component of a dotted import is a stdlib module name.
pub fn is_python_stdlib_top_level(import_dotted: &str) -> bool {
let top = import_dotted
.trim()
.split('.')
.next()
.unwrap_or("")
.trim();
!top.is_empty() && stdlib_names().contains(top)
}