Following from my earlier post, I've now solved the issue:

In Pyinstaller 2, instead of adding files to COLLECT, I just add the 
following after a = Analysis line in the spec file:

### STARTS HERE
def extra_datas(mycwd,mydir):
    import os
    oldcwd = os.getcwd()
    os.chdir( mycwd )
    
    def rec_glob(p, files):
        import os
        import glob
        for d in glob.glob(p):
            if os.path.isfile(d):
                files.append(d)
            rec_glob("%s/*" % d, files)
            
    files = []
    rec_glob("%s/*" % mydir, files)
    extra_datas = []
    for f in files:
        extra_datas.append((f, os.path.join(mycwd,f), 'DATA'))
        
    os.chdir( oldcwd )
    return extra_datas



# append the 'mydir' directory
mycwd= <path to parent folder of mydir>
a.datas += extra_datas(mycwd,mydir)

### ENDS HERE

I got the basic idea from http://stackoverflow.com/a/12033695/548598, but 
needed to adapt it to handle relative and absolute paths. This is because 
Pyinstaller uses the following pattern:
a.datas += [ ( <relativepath stored in dist>, <absolutepath of file to 
add>, DATA)]

I'm not sure if there is a way to avoid all the relative/absolute path 
hacks, but if there is, I'd like to know. Also, I read that TREE can be 
used to walk through a directory. However, I couldn't get this to work and 
had use the above script to walk through the directory myself.

Laurence.

>

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyinstaller?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to