2

I am trying to create an EXE of a python program. The program is quite complex and cannot be listed here. I have some user defined modules, halfwave, halfwave.utils and halfwave.db. I need to create a hook for these modules, so I have made files hook-halfwave.py, hook-halfwave.db.py and halfwave.utils.py and put in a folder called hooks. In the program I import the modules

from halfwave import ...
from halfwave.utils import ...
from halfwave.db import ...

But the hook files are never called by the pyinstaller. I have tried setting hookspath in the Analysis structure of the spec file and set the --additional-hooks-path switch. If I put the hook files in the pyinstaller hooks path, they get called, but that is not a good option. What is the trick for making the pyinstaller call the hook files?

EDIT: The command I run is

pyinstaller -y foo.spec

and the .spec file looks something like this

a = Analysis(['.\\src\\testfoo.py'],
         pathex=['C:\\Data\\python\\testfoo'],
         hiddenimports=[],
         hookspath='.\\hooks\\',
         runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
      a.scripts, ...

Also tried using the --additional-hooks-dir switch, but that makes no difference.

Thanks

thorsan
  • 1,034
  • 8
  • 19
  • Can you please edit your question with the full command line you are trying to execute, including the relevant switch for including your hook files? – Yoel May 24 '15 at 11:42
  • Have added the information about command line. – thorsan May 27 '15 at 06:54

1 Answers1

3

I think the hookspath argument should be a list of paths, as follows:

a = Analysis(['.\\src\\testfoo.py'],
         pathex=['C:\\Data\\python\\testfoo'],
         hiddenimports=[],
         hookspath=['.\\hooks\\'],
         runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
      a.scripts, ...
Yoel
  • 9,144
  • 7
  • 42
  • 57