Commit 12f981c5 by finswimmer Committed by Sébastien Eustace

FIX: Regression of not excluding files from build (#1606)

* FIX: To find excluded files, no additional glob is used to build a complete list of excluded files. Instead when checking if a file is excluded, it is looked up if one of the parent folder is in the excluded list.

* making isort happy

* revert accidentally made changes to pyproject.toml/poetry.lock

* fix: change condition for breaking loop, as previous version could lead to infinite loop
parent b29999c7
......@@ -11,7 +11,6 @@ from typing import Union
from clikit.api.io.flags import VERY_VERBOSE
from poetry.utils._compat import Path
from poetry.utils._compat import basestring
from poetry.utils._compat import glob
from poetry.utils._compat import lru_cache
from poetry.utils._compat import to_str
......@@ -84,15 +83,6 @@ class Builder(object):
explicitely_excluded = set()
for excluded_glob in self._package.exclude:
excluded_path = Path(self._path, excluded_glob)
try:
is_dir = excluded_path.is_dir()
except OSError:
# On Windows, testing if a path with a glob is a directory will raise an OSError
is_dir = False
if is_dir:
excluded_glob = Path(excluded_glob, "**/*")
for excluded in glob(
Path(self._path, excluded_glob).as_posix(), recursive=True
......@@ -112,10 +102,18 @@ class Builder(object):
return result
def is_excluded(self, filepath): # type: (Union[str, Path]) -> bool
if not isinstance(filepath, basestring):
filepath = filepath.as_posix()
exclude_path = Path(filepath)
while True:
if exclude_path.as_posix() in self.find_excluded_files():
return True
if len(exclude_path.parts) > 1:
exclude_path = exclude_path.parent
else:
break
return filepath in self.find_excluded_files()
return False
def find_files_to_add(self, exclude_build=True): # type: (bool) -> list
"""
......
......@@ -115,9 +115,9 @@ class WheelBuilder(Builder):
return
lib = lib[0]
excluded = self.find_excluded_files()
for pkg in lib.glob("**/*"):
if pkg.is_dir() or pkg in excluded:
if pkg.is_dir() or self.is_excluded(pkg):
continue
rel_path = str(pkg.relative_to(lib))
......@@ -132,7 +132,7 @@ class WheelBuilder(Builder):
self._add_file(wheel, pkg, rel_path)
def _copy_module(self, wheel):
excluded = self.find_excluded_files()
to_add = []
for include in self._module.includes:
......@@ -153,7 +153,7 @@ class WheelBuilder(Builder):
else:
rel_file = file.relative_to(self._path)
if rel_file.as_posix() in excluded:
if self.is_excluded(rel_file.as_posix()):
continue
if file.suffix == ".pyc":
......
......@@ -207,7 +207,7 @@ class Git:
args += ["ls-files", "--others", "-i", "--exclude-standard"]
output = self.run(*args)
return output.split("\n")
return output.strip().split("\n")
def remote_urls(self, folder=None): # type: (...) -> dict
output = self.run(
......
......@@ -9,7 +9,7 @@ license = "MIT"
readme = "README.rst"
exclude = ["my_package/data/", "**/*/item*"]
exclude = ["**/data/", "**/*/item*"]
homepage = "https://poetry.eustace.io/"
repository = "https://github.com/sdispater/poetry"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment