Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check .gitignore files in parent directories #2158

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&project_layout.project_root)
.hidden(false)
.parents(false)
.git_global(false)
.git_exclude(false)
.build()
{
let absolute = absolute?.into_path();
if !absolute.starts_with(package.as_path()) {
continue;
}
let relative = absolute.strip_prefix(python_dir).unwrap();
if absolute.is_dir() {
writer.add_directory(relative)?;
Expand Down
4 changes: 4 additions & 0 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const PYPROJECT_TOML: &str = "pyproject.toml";
/// Whether this project is pure rust or rust mixed with python and whether it has wheel data
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ProjectLayout {
/// Contains the absolute path to the project root directory
pub project_root: PathBuf,
/// Contains the absolute path to the python source directory
pub python_dir: PathBuf,
/// Contains the canonicalized (i.e. absolute) path to the python part of the project
Expand Down Expand Up @@ -397,6 +399,7 @@ impl ProjectLayout {
eprintln!("🍹 Building a mixed python/rust project");

Ok(ProjectLayout {
project_root: project_root.to_path_buf(),
python_dir: python_root,
python_packages,
python_module: Some(python_module),
Expand All @@ -415,6 +418,7 @@ impl ProjectLayout {
}

Ok(ProjectLayout {
project_root: project_root.to_path_buf(),
python_dir: python_root,
python_packages,
python_module: None,
Expand Down
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-implicit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-include-exclude/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-py-subdir/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-submodule/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed-with-path-dep/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
1 change: 1 addition & 0 deletions test-crates/pyo3-mixed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py[cdo]
2 changes: 2 additions & 0 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ fn pyo3_mixed_include_exclude_sdist() {
SdistGenerator::Cargo,
expect![[r#"
{
"pyo3_mixed_include_exclude-2.1.3/.gitignore",
"pyo3_mixed_include_exclude-2.1.3/Cargo.lock",
"pyo3_mixed_include_exclude-2.1.3/Cargo.toml",
"pyo3_mixed_include_exclude-2.1.3/PKG-INFO",
Expand Down Expand Up @@ -758,6 +759,7 @@ fn pyo3_mixed_include_exclude_git_sdist_generator() {
SdistGenerator::Git,
expect![[r#"
{
"pyo3_mixed_include_exclude-2.1.3/.gitignore",
"pyo3_mixed_include_exclude-2.1.3/Cargo.lock",
"pyo3_mixed_include_exclude-2.1.3/Cargo.toml",
"pyo3_mixed_include_exclude-2.1.3/PKG-INFO",
Expand Down
Loading