Stop converting package_data to extra_files in pysetup create (#13712).

pysetup create, the setup.cfg creation helper, used to convert
package_data (from an existing setup.py) into extra_files, the
replacement for MANIFEST.in, but these files are only present in sdists,
not installed: they don’t have the same use case at all, so converting
one into the other did not work.
This commit is contained in:
Éric Araujo 2012-02-05 10:26:16 +01:00
parent 31aefde876
commit dcfcb64582
3 changed files with 35 additions and 28 deletions

View File

@ -287,6 +287,7 @@ class MainProgram:
# optional string entries # optional string entries
if 'keywords' in self.data and self.data['keywords']: 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'])) fp.write('keywords = %s\n' % ' '.join(self.data['keywords']))
for name in ('home_page', 'author', 'author_email', for name in ('home_page', 'author', 'author_email',
'maintainer', 'maintainer_email', 'description-file'): 'maintainer', 'maintainer_email', 'description-file'):
@ -306,17 +307,29 @@ class MainProgram:
fp.write('%s = ' % name) fp.write('%s = ' % name)
fp.write(''.join(' %s\n' % val fp.write(''.join(' %s\n' % val
for val in self.data[name]).lstrip()) for val in self.data[name]).lstrip())
fp.write('\n[files]\n') 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]): if not(name in self.data and self.data[name]):
continue continue
fp.write('%s = %s\n' fp.write('%s = %s\n'
% (name, '\n '.join(self.data[name]).strip())) % (name, '\n '.join(self.data[name]).strip()))
fp.write('\nresources =\n')
for src, dest in self.data['resources']: if self.data.get('package_data'):
fp.write(' %s = %s\n' % (src, dest)) fp.write('package_data =\n')
fp.write('\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) os.chmod(_FILENAME, 0o644)
logger.info('Wrote "%s".' % _FILENAME) logger.info('Wrote "%s".' % _FILENAME)
@ -349,7 +362,6 @@ class MainProgram:
('long_description', 'description'), ('long_description', 'description'),
('url', 'home_page'), ('url', 'home_page'),
('platforms', 'platform'), ('platforms', 'platform'),
# backport only for 2.5+
('provides', 'provides-dist'), ('provides', 'provides-dist'),
('obsoletes', 'obsoletes-dist'), ('obsoletes', 'obsoletes-dist'),
('requires', 'requires-dist')) ('requires', 'requires-dist'))
@ -385,14 +397,8 @@ class MainProgram:
for src in srcs] for src in srcs]
data['resources'].extend(files) data['resources'].extend(files)
# 2.2 package_data -> extra_files # 2.2 package_data
package_dirs = dist.package_dir or {} data['package_data'] = dist.package_data.copy()
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_)
# Use README file if its content is the desciption # Use README file if its content is the desciption
if "description" in data: if "description" in data:

View File

@ -116,7 +116,6 @@ class CreateTestCase(support.TempdirManager,
package_data={ package_data={
'babar': ['Pom', 'Flora', 'Alexander'], 'babar': ['Pom', 'Flora', 'Alexander'],
'me': ['dady', 'mumy', 'sys', 'bro'], 'me': ['dady', 'mumy', 'sys', 'bro'],
'': ['setup.py', 'README'],
'pyxfoil': ['fengine.so'], 'pyxfoil': ['fengine.so'],
}, },
scripts=['my_script', 'bin/run'], scripts=['my_script', 'bin/run'],
@ -150,16 +149,15 @@ class CreateTestCase(support.TempdirManager,
mymodule mymodule
scripts = my_script scripts = my_script
bin/run bin/run
extra_files = Martinique/Lamentin/dady package_data =
Martinique/Lamentin/mumy babar = Pom
Martinique/Lamentin/sys Flora
Martinique/Lamentin/bro Alexander
setup.py me = dady
README mumy
Pom sys
Flora bro
Alexander pyxfoil = fengine.so
pyxfoil/fengine.so
resources = resources =
README.rst = {doc} README.rst = {doc}
@ -217,8 +215,9 @@ ho, baby!
[files] [files]
packages = pyxfoil packages = pyxfoil
extra_files = pyxfoil/fengine.so package_data =
pyxfoil/babar.so pyxfoil = fengine.so
babar.so
resources = resources =
README.rst = {doc} README.rst = {doc}

View File

@ -466,6 +466,8 @@ Core and Builtins
Library 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 #11805: package_data in setup.cfg should allow more than one value.
- Issue #13901: Prevent test_distutils failures on OS X with --enable-shared. - Issue #13901: Prevent test_distutils failures on OS X with --enable-shared.