3

I'm trying to bundle a cefpython1 application into a single exe with pyinstaller. I have a working spec file which creates a distrubiton for the cefpython1 example, cefsimple:

# -*- mode: python -*-

def get_cefpython_path():
    import cefpython1 as cefpython

    path = os.path.dirname(cefpython.__file__)
    return "%s%s" % (path, os.sep)

cefp = get_cefpython_path()

a = Analysis(['cefsimple.py'],
             hiddenimports=["json.decoder", "json.scanner", "json.encoder"])
pyz = PYZ(a.pure)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='cefsimple.exe',
          debug=False,
          strip=None,
          upx=False,
          console=False )
coll = COLLECT(exe,
               a.binaries + [('icudt.dll', '%s/icudt.dll' % cefp, 'BINARY')],
               a.zipfiles,
               a.datas + [('locales/en-US.pak', '%s/locales/en-US.pak' % cefp, 'DATA'), ('cefsimple.html', 'cefsimple.html', 'DATA'), ('icon.ico', 'icon.ico', 'DATA')],
               strip=None,
               upx=False,
               name='cefsimple')

The project files can be found on my Google Drive. Don't care about setup.py, it contains a py2exe build which i was playing with next to pyinstaller. You need Python 2.7, Win32gui, cefpython1 and of course pyinstaller packages to run this, I've tested this with the Win32 version only! I've even tried installing the development pyinstaller if it makes any change.

If i try to execute pyinstaller with the --onefile attribute seems like nothing changes, pyinstaller just creates the distribution directory under dist. The command I'm using is: pyinstaller --onefile cefsimple.spec

Tested --onefile with a simple Hello World python file and it does work by that. What's causing pyinstaller to not creating a single exe? The build log doesn't show anything interesting, but there are some things i don't understand in the warning file. For eg. it says there's no module named cefpython1.cefpython but the correct pyd is copied to the dist directory and the application is working anyway.

Here is the list of files created under dist/: cefsimple.lst Maybe this helps finding the problem.

NagyI
  • 5,907
  • 8
  • 55
  • 83

1 Answers1

1

The command I'm using is: pyinstaller --onefile cefsimple.spec

Tested --onefile with a simple Hello World python file and it does work by that. What's causing pyinstaller to not creating a single exe?

The option --onefile is ignored when you type pyinstaller --onefile cefsimple.spec because the .spec already defines if you will get a directory or a standalone file. A .spec file with a COLLECT function will make a whole dist directory.

I would suggest remaking a new .spec file by typing pyi-makespec --onefile cefsimple.py and adding back your various modifications (data, binaries, hiddenimports...), then trying pyinstaller cefsimple.spec without option. That works for me with pyinstaller 3.3.1.

Guimoute
  • 4,407
  • 3
  • 12
  • 28