Skip to content

Commit 91b68f9

Browse files
authored
Ignore .DS_Store on macOS (#1321)
1 parent e610877 commit 91b68f9

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

backend/src/hatchling/builders/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
# Mypy
2121
'.mypy_cache',
2222
))
23+
EXCLUDED_FILES = frozenset((
24+
# https://en.wikipedia.org/wiki/.DS_Store
25+
'.DS_Store',
26+
))
2327

2428

2529
class BuildEnvVars:

backend/src/hatchling/builders/plugin/interface.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import TYPE_CHECKING, Any, Callable, Generator, Generic, Iterable, cast
77

88
from hatchling.builders.config import BuilderConfig, BuilderConfigBound, env_var_enabled
9-
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, BuildEnvVars
9+
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, EXCLUDED_FILES, BuildEnvVars
1010
from hatchling.builders.utils import get_relative_path, safe_walk
1111
from hatchling.plugin.manager import PluginManagerBound
1212

@@ -191,6 +191,9 @@ def recurse_project_files(self) -> Iterable[IncludedFile]:
191191
files.sort()
192192
is_package = '__init__.py' in files
193193
for f in files:
194+
if f in EXCLUDED_FILES:
195+
continue
196+
194197
relative_file_path = os.path.join(relative_path, f)
195198
distribution_path = self.config.get_distribution_path(relative_file_path)
196199
if self.config.path_is_reserved(distribution_path):
@@ -218,6 +221,9 @@ def recurse_forced_files(self, inclusion_map: dict[str, str]) -> Iterable[Includ
218221

219222
files.sort()
220223
for f in files:
224+
if f in EXCLUDED_FILES:
225+
continue
226+
221227
relative_file_path = os.path.join(target_path, relative_directory, f)
222228
distribution_path = self.config.get_distribution_path(relative_file_path)
223229
if not self.config.path_is_reserved(distribution_path):
@@ -250,6 +256,9 @@ def recurse_explicit_files(self, inclusion_map: dict[str, str]) -> Iterable[Incl
250256
files.sort()
251257
is_package = '__init__.py' in files
252258
for f in files:
259+
if f in EXCLUDED_FILES:
260+
continue
261+
253262
relative_file_path = os.path.join(target_path, relative_directory, f)
254263
distribution_path = self.config.get_distribution_path(relative_file_path)
255264
if self.config.path_is_reserved(distribution_path):

docs/history/hatchling.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414

1515
***Added:***
1616

17+
- Metadata for the `wheel` target now defaults to the `PKG-INFO` metadata within source distributions
1718
- Add `dependencies` method to the build hook interface so that hooks can themselves dynamically define dependencies
1819
- Update the default version of core metadata to 2.3
1920
- Update SPDX license information to version 3.23
2021
- Improve error message for when the default heuristics for wheel file inclusion fail
2122

2223
***Fixed:***
2324

25+
- Properly support core metadata version 2.2
2426
- Remove `editables` as a direct dependency
2527
- Fix default wheel tag when the supported Python version declaration is strict
2628
- Load VCS ignore patterns first so that whitelisted patterns can be excluded by project configuration
2729
- Don't consider VCS ignore files that are outside of the VCS boundary
2830
- The `sdist` build target now gracefully ignores UNIX socket files
29-
- Metadata for the `wheel` target now defaults to the `PKG-INFO` metadata within source distributions
30-
- Properly support core metadata version 2.2
31+
- Begin ignoring certain files ubiquitously, like `.DS_Store` on macOS
3132

3233
## [1.21.1](https://github.com/pypa/hatch/releases/tag/hatchling-v1.21.1) - 2024-01-25 ## {: #hatchling-v1.21.1 }
3334

tests/backend/builders/plugin/test_interface.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from hatchling.builders.constants import EXCLUDED_DIRECTORIES
5+
from hatchling.builders.constants import EXCLUDED_DIRECTORIES, EXCLUDED_FILES
66
from hatchling.metadata.core import ProjectMetadata
77
from hatchling.plugin.manager import PluginManager
88

@@ -350,6 +350,9 @@ def test_order(self, temp_dir):
350350
excluded_dir = bar / name
351351
excluded_dir.ensure_dir_exists()
352352
(excluded_dir / 'file.ext').touch()
353+
for name in EXCLUDED_FILES:
354+
excluded_file = bar / name
355+
excluded_file.touch()
353356

354357
(project_dir / 'README.md').touch()
355358
(project_dir / 'tox.ini').touch()
@@ -367,6 +370,9 @@ def test_order(self, temp_dir):
367370
excluded_dir = external / name
368371
excluded_dir.ensure_dir_exists()
369372
(excluded_dir / 'file.ext').touch()
373+
for name in EXCLUDED_FILES:
374+
excluded_file = external / name
375+
excluded_file.touch()
370376

371377
assert [(f.path, f.distribution_path) for f in builder.recurse_included_files()] == [
372378
(str(project_dir / 'README.md'), 'README.md'),

0 commit comments

Comments
 (0)