Voo
Voo

Reputation: 30216

cx_freeze copies dll from wrong location

I'm using cx_freeze to generate an exe for a simple PyQt application with python 3.2 x86 under 64bit Windows.

The problem is that while cx_freeze copies all the dependencies perfectly fine together, it for some strange reason doesn't use the QtCore4.dll from my python install, but instead does the following:

copying D:\Python\Python 3.2 x86\lib\site-packages\PyQt4\QtCore.pyd -> build\exe.win32-3.2\PyQt4.QtCore.pyd
copying C:\Program Files\MiKTeX 2.9\miktex\bin\x64\QtCore4.dll (!!) -> build\exe.win32-3.2\QtCore4.dll

now that isn't much of a problem if I'm creating the 64bit version (although still not perfect), but clearly a 64bit dll won't work for my 32bit exe. So how do I get cx_freeze to stop looking in my system path for dlls and instead let it search in sys.path or some other path in my control?

I tried setting the path option to sys.path explicitly but to no avail.

Upvotes: 2

Views: 919

Answers (1)

Jesse Harris
Jesse Harris

Reputation: 1141

You have at least 3 options I can see based on the data provided:

1) You can add the option bin-path-excludes to the build_exe file with the paths you wish exclude from the process. Specific to your example:

bin-path-excludes: ["C:\Program Files\MiKTeX 2.9\miktex\bin\x64",] ,

2) Rearrange you PATH permanently so that the miktex entry comes later than the QtCore4.dll import you want to use.(this probably has consequences that preclude it from being a viable option)

3) Wrap the call to cx_freeze in a batch(or shell) script and manipulate the PATH in the script before calling the cx_freeze script.

I could not find any examples on the web for this sort of scenario so my research is based on reading the cx_freeze source code. There may very well be a more elegant technique but one was not apparent from neither the documentation nor the source code.

Upvotes: 2

Related Questions