Warn about files missing from the MANIFEST.
This commit is contained in:
parent
3bb9f47461
commit
f55e531f42
@ -118,6 +118,12 @@ class Packager(object):
|
|||||||
if not os.path.exists(self.config.dist_dir):
|
if not os.path.exists(self.config.dist_dir):
|
||||||
os.mkdir(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):
|
class BuildPackager(Packager):
|
||||||
def get_files(self):
|
def get_files(self):
|
||||||
files = self.config.bundle.get_files()
|
files = self.config.bundle.get_files()
|
||||||
@ -128,20 +134,22 @@ class BuildPackager(Packager):
|
|||||||
files = self.config.bundle.get_files()
|
files = self.config.bundle.get_files()
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def _list_useful_files(self):
|
def _check_manifest(self):
|
||||||
ignore_dirs = ['dist', '.git']
|
missing_files = []
|
||||||
ignore_files = ['.gitignore', 'MANIFEST', '*.pyc', '*~', '*.bak']
|
|
||||||
|
allfiles = self._list_files()
|
||||||
return list_files(self.config.source_dir, ignore_dirs, ignore_files)
|
for path in allfiles:
|
||||||
|
if path not in self.config.bundle.manifest:
|
||||||
|
missing_files.append(path)
|
||||||
|
|
||||||
|
return missing_files
|
||||||
|
|
||||||
def fix_manifest(self):
|
def fix_manifest(self):
|
||||||
manifest = self.config.bundle.manifest
|
manifest = self.config.bundle.manifest
|
||||||
|
|
||||||
allfiles = self._list_useful_files()
|
for path in self._check_manifest():
|
||||||
for path in allfiles:
|
manifest.append(path)
|
||||||
if path not in manifest:
|
|
||||||
manifest.append(path)
|
|
||||||
|
|
||||||
f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb")
|
f = open(os.path.join(self.config.source_dir, "MANIFEST"), "wb")
|
||||||
for line in manifest:
|
for line in manifest:
|
||||||
@ -157,15 +165,22 @@ class XOPackager(BuildPackager):
|
|||||||
bundle_zip = zipfile.ZipFile(self.package_path, 'w',
|
bundle_zip = zipfile.ZipFile(self.package_path, 'w',
|
||||||
zipfile.ZIP_DEFLATED)
|
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():
|
for f in self.get_files():
|
||||||
bundle_zip.write(os.path.join(self.config.source_dir, f),
|
bundle_zip.write(os.path.join(self.config.source_dir, f),
|
||||||
os.path.join(self.config.bundle_root_dir, f))
|
os.path.join(self.config.bundle_root_dir, f))
|
||||||
|
|
||||||
bundle_zip.close()
|
bundle_zip.close()
|
||||||
|
|
||||||
class SourcePackager(BuildPackager):
|
class SourcePackager(Packager):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
BuildPackager.__init__(self, config)
|
Packager.__init__(self, config)
|
||||||
self.package_path = os.path.join(self.config.dist_dir,
|
self.package_path = os.path.join(self.config.dist_dir,
|
||||||
self.config.tar_name)
|
self.config.tar_name)
|
||||||
|
|
||||||
@ -174,7 +189,7 @@ class SourcePackager(BuildPackager):
|
|||||||
cwd=self.config.source_dir)
|
cwd=self.config.source_dir)
|
||||||
if git_ls.wait():
|
if git_ls.wait():
|
||||||
# Fall back to filtered list
|
# Fall back to filtered list
|
||||||
return self._list_useful_files()
|
return self._list_files()
|
||||||
|
|
||||||
return [path.strip() for path in git_ls.stdout.readlines()]
|
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 dev - setup for development \n\
|
||||||
setup.py dist_xo - create a xo bundle package \n\
|
setup.py dist_xo - create a xo bundle package \n\
|
||||||
setup.py dist_source - create a tar source 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 install [dirname] - install the bundle \n\
|
||||||
setup.py uninstall [dirname] - uninstall the bundle \n\
|
setup.py uninstall [dirname] - uninstall the bundle \n\
|
||||||
setup.py genpot - generate the gettext pot file \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 = XOPackager(config)
|
||||||
packager.package()
|
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):
|
def cmd_dist(config, options, args):
|
||||||
logging.warn("dist deprecated, use dist_xo.")
|
logging.warn("dist deprecated, use dist_xo.")
|
||||||
cmd_dist_xo(config, options, args)
|
cmd_dist_xo(config, options, args)
|
||||||
|
Loading…
Reference in New Issue
Block a user