-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate license-files glob patterns #4841
Conversation
4257919
to
b50f10b
Compare
setuptools/dist.py
Outdated
def _validate_and_expand_pattern(self, pattern): | ||
"""Validate license file patterns according to the PyPA specifications. | ||
https://packaging.python.org/en/latest/specifications/pyproject-toml/#license-files | ||
""" | ||
if ".." in pattern: | ||
raise InvalidConfigError( | ||
f"License file pattern '{pattern}' cannot contain '..'" | ||
) | ||
if pattern.startswith((os.sep, "/")) or ":\\" in pattern: | ||
raise InvalidConfigError( | ||
f"License file pattern '{pattern}' should be relative and " | ||
"must not start with '/'" | ||
) | ||
if _license_files_allowed_chars.match(pattern) is None: | ||
raise InvalidConfigError( | ||
f"License file pattern '{pattern}' contains invalid " | ||
"characters. " | ||
"https://packaging.python.org/en/latest/specifications/pyproject-toml/#license-files" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similar to the validation pattern I added in flit
a few weeks ago. pypa/flit#705
b50f10b
to
6c0156f
Compare
Thank you very much @cdce8p. I think I would like to absorb some of these validations into #4838. We will need to convert the exceptions into deprecation warnings as there is a change builds start to fail It is a bit annoying that PEP 638 is so heavy in terms of mandatory validations... |
Alternative approach to #4838.
Validate each pattern and raise an exception if it is invalid or a pattern doesn't match any license files.
This will also apply to existing configs with
license-files
insetup.cfg
andtools.setuptools.license-files
, however I don't think that's an issue as these are almost always real problems and easy to fix.Ref: #4829