diff options
author | Alan Fregtman <941331+darkvertex@users.noreply.github.com> | 2021-07-21 17:34:14 -0400 |
---|---|---|
committer | Alan Fregtman <941331+darkvertex@users.noreply.github.com> | 2021-07-21 17:34:14 -0400 |
commit | cb05fb0c94716b1d328ecca0573346218505b859 (patch) | |
tree | f2d840011187536a354e2f76e94a7d2e706e1b9b /setuptools/config.py | |
parent | b2a25766c443cba5c474ff73d46c40c47c5e7c3e (diff) | |
download | python-setuptools-git-cb05fb0c94716b1d328ecca0573346218505b859.tar.gz |
Update globbing for [options.data_files] to be implicit, not requiring a custom directive.
Diffstat (limited to 'setuptools/config.py')
-rw-r--r-- | setuptools/config.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/setuptools/config.py b/setuptools/config.py index 84672597..6e7c64e7 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -258,27 +258,36 @@ class ConfigHandler: @classmethod def _parse_list_glob(cls, value, separator=','): - """Equivalent to _parse_list() but expands 'glob:' directives using glob(). + """Equivalent to _parse_list() but expands any glob patterns using glob(). - However, unlike glob(), the resolved results stay relative paths. + However, unlike direct calls to glob(), the resolved results remain relative paths. :param value: :param separator: List items separator character. :rtype: list """ - directive = 'glob:' + glob_characters = ('*', '?', '[', ']', '{', '}') + get_relpath = lambda value: os.path.relpath(value, os.getcwd()) values = cls._parse_list(value, separator=separator) expanded_values = [] for value in values: trimmed_value = value.strip() - if trimmed_value.startswith(directive): - # take what is after "glob:" - value = trimmed_value.split(directive, 1)[-1].strip() + + # Has globby characters? + if any(char in value for char in glob_characters): value = os.path.abspath(value) - # and expand it while keeping as a relative path: + + # check if this path has globby characters but does in fact exist: + if os.path.exists(value): + # if it does, treat it literally and do not expand any patterns: + expanded_values.append(get_relpath(value)) + continue + + # else expand the glob pattern while keeping paths *relative*: value = sorted( - os.path.relpath(path, os.getcwd()) for path in iglob(value)) + get_relpath(path) for path in iglob(value)) expanded_values.extend(value) + else: expanded_values.append(value) |