From beea7b48ec56e318f43a62eebb03577d7d91a31e Mon Sep 17 00:00:00 2001 From: Brecht Machiels Date: Thu, 21 Jan 2021 13:18:53 +0100 Subject: [PATCH 1/5] Log all files being added --- poetry/core/masonry/builders/builder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/poetry/core/masonry/builders/builder.py b/poetry/core/masonry/builders/builder.py index c6f6d9cd6..fc433d6c6 100644 --- a/poetry/core/masonry/builders/builder.py +++ b/poetry/core/masonry/builders/builder.py @@ -165,6 +165,7 @@ def find_files_to_add( if not current_file.is_dir() and not self.is_excluded( include_file.relative_to_source_root() ): + logger.debug("Adding: {}".format(str(current_file))) to_add.add(include_file) continue From 275e5a436531fa8aac5f0d195ab69f4a7acbc5de Mon Sep 17 00:00:00 2001 From: Brecht Machiels Date: Thu, 21 Jan 2021 13:10:56 +0100 Subject: [PATCH 2/5] Pass unresolved paths to is_excluded() This makes is_excluded work with symlinks. --- poetry/core/masonry/builders/builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poetry/core/masonry/builders/builder.py b/poetry/core/masonry/builders/builder.py index fc433d6c6..4fe2b7b80 100644 --- a/poetry/core/masonry/builders/builder.py +++ b/poetry/core/masonry/builders/builder.py @@ -163,7 +163,7 @@ def find_files_to_add( ) if not current_file.is_dir() and not self.is_excluded( - include_file.relative_to_source_root() + current_file.relative_to(self._path) ): logger.debug("Adding: {}".format(str(current_file))) to_add.add(include_file) @@ -183,7 +183,7 @@ def find_files_to_add( ) if self.is_excluded( - include_file.relative_to_project_root() + file.relative_to(source_root) ) and isinstance(include, PackageInclude): continue From 26217e1b5b3a8ed0d65e5f3a98bd3aefe798c63e Mon Sep 17 00:00:00 2001 From: Brecht Machiels Date: Thu, 21 Jan 2021 13:15:43 +0100 Subject: [PATCH 3/5] 'exclude' should be able to override 'include' matches Note that this behavior was different for files in dirs; see "if file.is_dir():" block a bit higher in the code. Related: python-poetry/poetry#1336 --- poetry/core/masonry/builders/builder.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/poetry/core/masonry/builders/builder.py b/poetry/core/masonry/builders/builder.py index 4fe2b7b80..b744fc567 100644 --- a/poetry/core/masonry/builders/builder.py +++ b/poetry/core/masonry/builders/builder.py @@ -182,9 +182,7 @@ def find_files_to_add( path=file, project_root=self._path, source_root=source_root ) - if self.is_excluded( - file.relative_to(source_root) - ) and isinstance(include, PackageInclude): + if self.is_excluded(file.relative_to(source_root)): continue if file.suffix == ".pyc": From 77a46109a40721da87a18e1188635b9a944e5f3d Mon Sep 17 00:00:00 2001 From: Brecht Machiels Date: Thu, 21 Jan 2021 13:34:40 +0100 Subject: [PATCH 4/5] Some remarks --- poetry/core/masonry/builders/builder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/poetry/core/masonry/builders/builder.py b/poetry/core/masonry/builders/builder.py index b744fc567..d29c03040 100644 --- a/poetry/core/masonry/builders/builder.py +++ b/poetry/core/masonry/builders/builder.py @@ -153,8 +153,10 @@ def find_files_to_add( if "__pycache__" in str(file): continue + # this should be moved to Include.check_elements(), similar + # to PackageInclude.check_elements() if file.is_dir(): - if self.format in formats: + if self.format in formats: # why check this only for dirs? for current_file in file.glob("**/*"): include_file = BuildIncludeFile( path=current_file, From 65854684aca00e69e0725d4385910ac0126866d5 Mon Sep 17 00:00:00 2001 From: Brecht Machiels Date: Thu, 21 Jan 2021 13:48:00 +0100 Subject: [PATCH 5/5] Exclude .git directories and files in them by default Note that this makes a list of all files in .git directories and is thus very slow. --- poetry/core/vcs/git.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/poetry/core/vcs/git.py b/poetry/core/vcs/git.py index c060ec060..7bb9c0755 100644 --- a/poetry/core/vcs/git.py +++ b/poetry/core/vcs/git.py @@ -256,8 +256,9 @@ def get_ignored_files(self, folder=None): # type: (...) -> list args += ["ls-files", "--others", "-i", "--exclude-standard"] output = self.run(*args) + dotgit = list(str(path.relative_to(folder)) for path in folder.rglob(".git/*")) - return output.strip().split("\n") + return dotgit + output.strip().split("\n") def remote_urls(self, folder=None): # type: (...) -> dict output = self.run(