diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py index 5abe47b37dd..3d45ca9f90e 100644 --- a/Lib/packaging/create.py +++ b/Lib/packaging/create.py @@ -287,6 +287,7 @@ def _write_cfg(self): # optional string entries if 'keywords' in self.data and self.data['keywords']: + # XXX shoud use comma to separate, not space fp.write('keywords = %s\n' % ' '.join(self.data['keywords'])) for name in ('home_page', 'author', 'author_email', 'maintainer', 'maintainer_email', 'description-file'): @@ -306,17 +307,29 @@ def _write_cfg(self): fp.write('%s = ' % name) fp.write(''.join(' %s\n' % val for val in self.data[name]).lstrip()) + fp.write('\n[files]\n') - for name in ('packages', 'modules', 'scripts', - 'package_data', 'extra_files'): + + for name in ('packages', 'modules', 'scripts', 'extra_files'): if not(name in self.data and self.data[name]): continue fp.write('%s = %s\n' % (name, '\n '.join(self.data[name]).strip())) - fp.write('\nresources =\n') - for src, dest in self.data['resources']: - fp.write(' %s = %s\n' % (src, dest)) - fp.write('\n') + + if self.data.get('package_data'): + fp.write('package_data =\n') + for pkg, spec in sorted(self.data['package_data'].items()): + # put one spec per line, indented under the package name + indent = ' ' * (len(pkg) + 7) + spec = ('\n' + indent).join(spec) + fp.write(' %s = %s\n' % (pkg, spec)) + fp.write('\n') + + if self.data.get('resources'): + fp.write('resources =\n') + for src, dest in self.data['resources']: + fp.write(' %s = %s\n' % (src, dest)) + fp.write('\n') os.chmod(_FILENAME, 0o644) logger.info('Wrote "%s".' % _FILENAME) @@ -349,7 +362,6 @@ def setup_mock(**attrs): ('long_description', 'description'), ('url', 'home_page'), ('platforms', 'platform'), - # backport only for 2.5+ ('provides', 'provides-dist'), ('obsoletes', 'obsoletes-dist'), ('requires', 'requires-dist')) @@ -385,14 +397,8 @@ def setup_mock(**attrs): for src in srcs] data['resources'].extend(files) - # 2.2 package_data -> extra_files - package_dirs = dist.package_dir or {} - for package, extras in dist.package_data.items() or []: - package_dir = package_dirs.get(package, package) - for file_ in extras: - if package_dir: - file_ = package_dir + '/' + file_ - data['extra_files'].append(file_) + # 2.2 package_data + data['package_data'] = dist.package_data.copy() # Use README file if its content is the desciption if "description" in data: diff --git a/Lib/packaging/tests/test_create.py b/Lib/packaging/tests/test_create.py index 07824b1aa82..76bc3316b42 100644 --- a/Lib/packaging/tests/test_create.py +++ b/Lib/packaging/tests/test_create.py @@ -116,7 +116,6 @@ def test_convert_setup_py_to_cfg(self): package_data={ 'babar': ['Pom', 'Flora', 'Alexander'], 'me': ['dady', 'mumy', 'sys', 'bro'], - '': ['setup.py', 'README'], 'pyxfoil': ['fengine.so'], }, scripts=['my_script', 'bin/run'], @@ -150,16 +149,15 @@ def test_convert_setup_py_to_cfg(self): mymodule scripts = my_script bin/run - extra_files = Martinique/Lamentin/dady - Martinique/Lamentin/mumy - Martinique/Lamentin/sys - Martinique/Lamentin/bro - setup.py - README - Pom - Flora - Alexander - pyxfoil/fengine.so + package_data = + babar = Pom + Flora + Alexander + me = dady + mumy + sys + bro + pyxfoil = fengine.so resources = README.rst = {doc} @@ -217,8 +215,9 @@ def test_convert_setup_py_to_cfg_with_description_in_readme(self): [files] packages = pyxfoil - extra_files = pyxfoil/fengine.so - pyxfoil/babar.so + package_data = + pyxfoil = fengine.so + babar.so resources = README.rst = {doc} diff --git a/Misc/NEWS b/Misc/NEWS index 91972bf2b2e..41fc63ecb01 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -466,6 +466,8 @@ Core and Builtins Library ------- +- Issue #13712: pysetup create should not convert package_data to extra_files. + - Issue #11805: package_data in setup.cfg should allow more than one value. - Issue #13901: Prevent test_distutils failures on OS X with --enable-shared.