Skip to content

Commit dd0c994

Browse files
committed
Convert error for license files into deprecation warning
1 parent f577461 commit dd0c994

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

setuptools/dist.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,20 +496,30 @@ def _find_pattern(pattern: str, enforce_match: bool = True) -> list[str]:
496496
>>> Distribution._find_pattern("../LICENSE.MIT")
497497
Traceback (most recent call last):
498498
...
499-
setuptools.errors.InvalidConfigError: ...Pattern '../LICENSE.MIT' cannot contain '..'
499+
setuptools.warnings.SetuptoolsDeprecationWarning: ...Pattern '../LICENSE.MIT' cannot contain '..'
500500
>>> Distribution._find_pattern("LICEN{CSE*")
501501
Traceback (most recent call last):
502502
...
503503
setuptools.warnings.SetuptoolsDeprecationWarning: ...Pattern 'LICEN{CSE*' contains invalid characters...
504504
"""
505+
pypa_guides = "specifications/glob-patterns/"
505506
if ".." in pattern:
506-
raise InvalidConfigError(f"Pattern {pattern!r} cannot contain '..'")
507+
SetuptoolsDeprecationWarning.emit(
508+
f"Pattern {pattern!r} cannot contain '..'",
509+
"""
510+
According to the new PyPA standards, this glob pattern is invalid.
511+
Please ensure the files specified are contained by the root
512+
of the Python package (normally marked by `pyproject.toml`).
513+
""",
514+
see_url=f"https://packaging.python.org/en/latest/{pypa_guides}",
515+
due_date=(2026, 2, 20), # Introduced in 2025-03-20
516+
# Replace with InvalidConfigError after deprecation
517+
)
507518
if pattern.startswith((os.sep, "/")) or ":\\" in pattern:
508519
raise InvalidConfigError(
509520
f"Pattern {pattern!r} should be relative and must not start with '/'"
510521
)
511522
if re.match(r'^[\w\-\.\/\*\?\[\]]+$', pattern) is None:
512-
pypa_guides = "specifications/glob-patterns/"
513523
SetuptoolsDeprecationWarning.emit(
514524
"Please provide a valid glob pattern.",
515525
"Pattern {pattern!r} contains invalid characters.",

0 commit comments

Comments
 (0)