Skip to content

Commit 239547e

Browse files
committed
Small fix for target-specific artifacts
1 parent 2cb32cd commit 239547e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

check_dist/_core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,10 @@ def check_sdist_vs_vcs(
633633
# Artifacts are built files not in VCS but expected in dists
634634
artifacts = hatch_config.get("artifacts", [])
635635

636+
# There are also artifact sections in sdist and wheel config that should be considered when comparing against VCS
637+
sdist_artifacts = hatch_config.get("targets", {}).get("sdist", {}).get("artifacts", [])
638+
artifacts.extend(sdist_artifacts)
639+
636640
# "Extra" = files in sdist that are neither VCS-tracked nor
637641
# generated artifacts. This catches truly stray files.
638642
extra = sorted(sdist_set - vcs_set)

check_dist/tests/test_all.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ def test_artifacts_not_flagged_as_extra(self):
328328
errors = check_sdist_vs_vcs(sdist, vcs, hatch)
329329
assert errors == []
330330

331+
def test_artifacts_in_sdist_section(self):
332+
"""Artifacts listed in hatch sdist config should also be ignored."""
333+
sdist = ["pkg/extension/index.js", "pkg/__init__.py", "pyproject.toml"]
334+
vcs = ["pkg/__init__.py", "pyproject.toml"]
335+
hatch = {"targets": {"sdist": {"artifacts": ["pkg/extension"]}}}
336+
errors = check_sdist_vs_vcs(sdist, vcs, hatch)
337+
assert errors == []
338+
331339
def test_only_include_vcs_check(self):
332340
"""only-include config should scope the VCS comparison."""
333341
sdist = ["pkg/__init__.py", "rust/lib.rs", "Cargo.toml", "pyproject.toml"]

0 commit comments

Comments
 (0)