Warn about files missing from the MANIFEST.

This commit is contained in:
Marco Pesenti Gritti 2008-08-22 15:03:01 +02:00
parent 3bb9f47461
commit f55e531f42

View File

@ -118,6 +118,12 @@ class Packager(object):
if not os.path.exists(self.config.dist_dir):
os.mkdir(self.config.dist_dir)
def _list_files(self):
ignore_dirs = ['dist', '.git']
ignore_files = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak']
return list_files(self.config.source_dir, ignore_dirs, ignore_files)
class BuildPackager(Packager):
def get_files(self):
files = self.config.bundle.get_files()
@ -129,19 +135,21 @@ class BuildPackager(Packager):
return files
def _list_useful_files(self):
ignore_dirs = ['dist', '.git']
ignore_files = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak']
def _check_manifest(self):
missing_files = []
return list_files(self.config.source_dir, ignore_dirs, ignore_files)
allfiles = self._list_files()
for path in allfiles:
if path not in self.config.bundle.manifest:
missing_files.append(path)
return missing_files
def fix_manifest(self):
manifest = self.config.bundle.manifest
allfiles = self._list_useful_files()
for path in allfiles:
if path not in manifest:
manifest.append(path)
for path in self._check_manifest():
manifest.append(path)
f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb")
for line in manifest:
@ -157,15 +165,22 @@ class XOPackager(BuildPackager):
bundle_zip = zipfile.ZipFile(self.package_path, 'w',
zipfile.ZIP_DEFLATED)
missing_files = self._check_manifest()
if missing_files:
logging.warn('These files are not included in the manifest ' \
'and will not be present in the bundle:\n\n' +
'\n'.join(missing_files) +
'\n\nUse fix_manifest if you want to add them.')
for f in self.get_files():
bundle_zip.write(os.path.join(self.config.source_dir, f),
os.path.join(self.config.bundle_root_dir, f))
bundle_zip.close()
class SourcePackager(BuildPackager):
class SourcePackager(Packager):
def __init__(self, config):
BuildPackager.__init__(self, config)
Packager.__init__(self, config)
self.package_path = os.path.join(self.config.dist_dir,
self.config.tar_name)
@ -174,7 +189,7 @@ class SourcePackager(BuildPackager):
cwd=self.config.source_dir)
if git_ls.wait():
# Fall back to filtered list
return self._list_useful_files()
return self._list_files()
return [path.strip() for path in git_ls.stdout.readlines()]
@ -191,6 +206,7 @@ setup.py build - build generated files \n\
setup.py dev - setup for development \n\
setup.py dist_xo - create a xo bundle package \n\
setup.py dist_source - create a tar source package \n\
setup.py fix_manifest - add missing files to the manifest \n\
setup.py install [dirname] - install the bundle \n\
setup.py uninstall [dirname] - uninstall the bundle \n\
setup.py genpot - generate the gettext pot file \n\
@ -218,6 +234,13 @@ def cmd_dist_xo(config, options, args):
packager = XOPackager(config)
packager.package()
def cmd_fix_manifest(config, options, args):
builder = Builder(config)
builder.build()
packager = XOPackager(config)
packager.fix_manifest()
def cmd_dist(config, options, args):
logging.warn("dist deprecated, use dist_xo.")
cmd_dist_xo(config, options, args)