Allow multiple values for package_data in setup.cfg (#11805).

Even though the resources system obsoletes data_files and package_data
(see bug discussion), package_data still exists to allow compatibility
with distutils and thus an easier transition.  In setup.py, the values
are lists of glob patterns, so the setup.cfg syntax needed a way to
express multiple values too.

Doc for this option will be added later as part of the big packaging doc
patches.  For now, the test serves as example.

Reported by Erik Bray.
This commit is contained in:
Éric Araujo 2012-02-04 21:53:07 +01:00
parent 591f6e82bd
commit 31aefde876
3 changed files with 50 additions and 14 deletions

View file

@ -20,7 +20,6 @@ def _check_name(name, packages):
if '.' not in name:
return
parts = name.split('.')
modname = parts[-1]
parent = '.'.join(parts[:-1])
if parent not in packages:
# we could log a warning instead of raising, but what's the use
@ -227,13 +226,25 @@ class Config:
self.dist.scripts = [self.dist.scripts]
self.dist.package_data = {}
# bookkeeping for the loop below
firstline = True
prev = None
for line in files.get('package_data', []):
data = line.split('=')
if len(data) != 2:
raise ValueError('invalid line for package_data: %s '
'(misses "=")' % line)
key, value = data
self.dist.package_data[key.strip()] = value.strip()
if '=' in line:
# package name -- file globs or specs
key, value = line.split('=')
prev = self.dist.package_data[key.strip()] = value.split()
elif firstline:
# invalid continuation on the first line
raise PackagingOptionError(
'malformed package_data first line: %r (misses "=")' %
line)
else:
# continuation, add to last seen package name
prev.extend(line.split())
firstline = False
self.dist.data_files = []
for data in files.get('data_files', []):