Frage

I am developing an cross platform application which ships additional binary files from source directory for linux and windows. Right now I am using following script in my *.spec file to include all binaries from the source directory.

##### include mydir in distribution #######
def extra_datas(mydir):
    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, f, 'DATA'))

    return extra_datas
###########################################

# append the 'data' dir
a.datas += extra_datas('data')

All works well. Now the issue is that when i create binay from windows, all additional binaries of linux also shiped in the final executable. This makes the final stand alone executable bigger in size.

Is there a way to tell pyinstaller to execlude certain files/ binarries from source directory. Also is it possible to execlude certain *.so/ *.dll which are really not required in the final executable?

I use the following for development:-

Python 2.7

Pyinstaller 2.1

Debian 7 for linux

Windows 7 for Win

Any help is appriciated.

War es hilfreich?

Lösung

sure just add a list of files to exclude

def extra_datas(mydir,exclude=[]):
    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)
    return [(f, f, 'DATA') for f om files if f not in exclude]

a.datas += extra_datas(some_dir,["something.txt","something.exe",...])

as for DLL's im pretty sure there is an explicit exlude to exclude dll's that would normally automagically be included

[edit] see this answer wrt excluding dll's https://stackoverflow.com/a/17595149/541038

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top