From 37b5db05def431c50ea3f244fd6215472a3ca553 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sun, 18 Sep 2022 19:26:41 -0400 Subject: [PATCH] More directories that cannot be traversed --- backend/src/hatchling/builders/config.py | 4 +--- backend/src/hatchling/builders/constants.py | 19 ++++++++++++++++++- docs/history.md | 4 ++++ tests/backend/builders/test_config.py | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/backend/src/hatchling/builders/config.py b/backend/src/hatchling/builders/config.py index 329b22bb8..90938fc90 100644 --- a/backend/src/hatchling/builders/config.py +++ b/backend/src/hatchling/builders/config.py @@ -787,9 +787,7 @@ def default_packages(self): return [] def default_global_exclude(self): - patterns = ['*.py[cdo]', *EXCLUDED_DIRECTORIES] - patterns.sort() - return patterns + return ['*.py[cdo]', f'/{DEFAULT_BUILD_DIRECTORY}'] def get_force_include(self): force_include = self.force_include.copy() diff --git a/backend/src/hatchling/builders/constants.py b/backend/src/hatchling/builders/constants.py index 73c690d04..d25af73a0 100644 --- a/backend/src/hatchling/builders/constants.py +++ b/backend/src/hatchling/builders/constants.py @@ -1,6 +1,23 @@ DEFAULT_BUILD_DIRECTORY = 'dist' -EXCLUDED_DIRECTORIES = frozenset(('.git', '__pycache__')) +EXCLUDED_DIRECTORIES = frozenset( + ( + # Python bytecode + '__pycache__', + # PEP 582 + '__pypackages__', + # Git + '.git', + # Mercurial + '.hg', + # Hatch + '.hatch', + # tox + '.tox', + # nox + '.nox', + ) +) class BuildEnvVars: diff --git a/docs/history.md b/docs/history.md index 4d8bf1315..51dac907a 100644 --- a/docs/history.md +++ b/docs/history.md @@ -175,6 +175,10 @@ This is the first stable release of Hatch v1, a complete rewrite. Enjoy! ### Unreleased +***Added:*** + +- Add the following to the list of directories that cannot be traversed: `__pypackages__`, `.hg`, `.hatch`, `.tox`, `.nox` + ***Fixed:*** - Improve tracking of dynamic metadata diff --git a/tests/backend/builders/test_config.py b/tests/backend/builders/test_config.py index 23a947a29..ca1e6783e 100644 --- a/tests/backend/builders/test_config.py +++ b/tests/backend/builders/test_config.py @@ -1608,7 +1608,7 @@ def test_packages(self, isolation): def test_global_exclude(self, isolation): builder = Builder(str(isolation)) - assert builder.config.default_global_exclude() == ['*.py[cdo]', '.git', '__pycache__'] + assert builder.config.default_global_exclude() == ['*.py[cdo]', '/dist'] class TestPatternInclude: