summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/config.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2012-02-04 20:53:07 (GMT)
committerÉric Araujo <merwok@netwok.org>2012-02-04 20:53:07 (GMT)
commit31aefde8760c3d407ffe8dc044e5ae8f5daeb12c (patch)
tree603b62a6b4d6fee4d984dcf112526cd178e4bae1 /Lib/packaging/config.py
parent591f6e82bd24361b7628bcb47830e18efb354db2 (diff)
downloadcpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.zip
cpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.tar.gz
cpython-31aefde8760c3d407ffe8dc044e5ae8f5daeb12c.tar.bz2
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.
Diffstat (limited to 'Lib/packaging/config.py')
-rw-r--r--Lib/packaging/config.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/Lib/packaging/config.py b/Lib/packaging/config.py
index 366faea..ab026a8 100644
--- a/Lib/packaging/config.py
+++ b/Lib/packaging/config.py
@@ -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', []):