Custom archives can be created by providing a function named "dist" in the top-level script file. The following example prints a checksum immediately after the archive is created:
VERSION = '0.0.1' APPNAME = 'cpp_test' def dist(): import md5 from Scripting import dist (f, filename) = dist(APPNAME, VERSION) f = file(filename,'rb') m = md5.md5() readBytes = 100000 while (readBytes): readString = f.read(readBytes) m.update(readString) readBytes = len(readString) f.close() print(filename, m.hexdigest()) sys.exit(0)
A function may be defined for excluding or adding more files to the archive. The hook is executed from the temporary directory after the dist function has finished to run:
def dist_hook(): os.remove('foo.txt')
When copying the files, the dist function automatically excludes temporary files. The function dont_dist in the module Scripting does the filtering, the code is reproduced below:
excludes = '.svn CVS .arch-ids {arch} SCCS BitKeeper .hg'.split() dist_exts = '~ .rej .orig .pyc .pyo .bak config.log .tar.bz2 .zip Makefile Makefile.in'.split() def dont_dist(name, src, build_dir): global excludes, dist_exts if (name.startswith(',,') or name.startswith('++') or (src == '.' and name == Options.lockfile) or name in excludes or name == build_dir ): return True for ext in dist_exts: if name.endswith(ext): return True return False
To exclude new files, it is possible to modify the extensions, or to provide a new method dont_dist, for example, to disable most of the filtering:
import Scripting def dont_dist(name, src, build_dir): if (name == build_dir or (src == '.' and name == Options.lockfile)): return True return False