wiki:Recipe/CollectDatafiles
Last modified 7 months ago Last modified on 10/13/11 14:22:45

Collect Data Files

The Recipe

Put the following snippet into you .spec file:

def Datafiles(*filenames, **kw):
    import os
    
    def datafile(path, strip_path=True):
        parts = path.split('/')
        path = name = os.path.join(*parts)
        if strip_path:
            name = os.path.basename(path)
        return name, path, 'DATA'

    strip_path = kw.get('strip_path', True)
    return TOC(
        datafile(filename, strip_path=strip_path)
        for filename in filenames
        if os.path.isfile(filename))

Now collect your datafiles ...

docfiles = Datafiles('LICENSE-GPLv3.txt', 'doc/pdfposter.html')

... and add the collected file to the COLLECT()

coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               docfiles,
               name=os.path.join('dist', 'pdfposter'))