diff --git a/src/module_writer.rs b/src/module_writer.rs index 309d0890b..4ad7cf3de 100644 --- a/src/module_writer.rs +++ b/src/module_writer.rs @@ -1286,8 +1286,17 @@ pub fn write_python_part( } for package in python_packages { - for absolute in WalkBuilder::new(package).hidden(false).build() { + for absolute in WalkBuilder::new(python_dir) + .hidden(false) + .parents(false) + .git_global(false) + .git_exclude(false) + .build() + { let absolute = absolute?.into_path(); + if !absolute.starts_with(package.clone()) { + continue; + } let relative = absolute.strip_prefix(python_dir).unwrap(); if absolute.is_dir() { writer.add_directory(relative)?;