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

Add support for excluding files from wheels by .gitignore #695

Merged
merged 1 commit into from
Nov 23, 2021
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
61 changes: 60 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ structopt = "0.3.21"
tar = "0.4.33"
tempfile = "3.2.0"
toml = "0.5.8"
walkdir = "2.3.1"
zip = "0.5.5"
thiserror = "1.0.24"
dirs = { version = "4.0.0", optional = true }
Expand All @@ -58,6 +57,7 @@ target-lexicon = "0.12.0"
pyproject-toml = "0.3.0"
python-pkginfo = "0.5.0"
textwrap = "0.14.2"
ignore = "0.4.18"

[dev-dependencies]
indoc = "1.0.3"
Expand Down
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* Add support for excluding files from wheels by `.gitignore` in [#695](https://github.com/PyO3/maturin/pull/695)

## [0.12.1] - 2021-11-21

* Add support for cross compiling PyPy wheels in [#687](https://github.com/PyO3/maturin/pull/687)
Expand Down
5 changes: 3 additions & 2 deletions src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::str;
use tempfile::{tempdir, TempDir};
use walkdir::WalkDir;
use zip::{self, ZipWriter};

/// Allows writing the module to a wheel or add it directly to the virtualenv
Expand Down Expand Up @@ -771,7 +770,9 @@ pub fn write_python_part(
python_module: impl AsRef<Path>,
module_name: impl AsRef<Path>,
) -> Result<()> {
for absolute in WalkDir::new(&python_module) {
use ignore::WalkBuilder;

for absolute in WalkBuilder::new(&python_module).hidden(false).build() {
let absolute = absolute?.into_path();

let relative = absolute.strip_prefix(python_module.as_ref().parent().unwrap())?;
Expand Down