I had to escape the double quotes in setup.py that set the LIBDIR macro.
Additionally I had to change the cxfreeze-postinstall script, because there is no Scripts folder for a mingw python installation. This overlaps with the pull request #21.
After this I was able to compile and freeze python programs. Hooray!
Though none of the frozen programs actually worked. Not even the simple example program.
I kept getting the error Unable to calculate directory of executable!
// get directory from executable namestrcpy(g_ExecutableDirName,g_ExecutableName);ptr=strrchr(g_ExecutableDirName,SEP);if(!ptr)returnFatalError("Unable to calculate directory of executable!");*ptr='\0';
The reason was that SEP as defined in osdefs.h in Python set it to '/', but the path returned by GetModuleFileName has '\\'. So strrchr fails.
/* Mod by chrish: QNX has WATCOM, but isn't DOS */#if !defined(__QNX__)#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2)#if defined(PYOS_OS2) && defined(PYCC_GCC)#define MAXPATHLEN 260#define SEP '/'#define ALTSEP '\\'#else#define SEP '\\'#define ALTSEP '/'#define MAXPATHLEN 256#endif#define DELIM ';'#endif#endif/* Filename separator */#ifndef SEP#define SEP '/'#endif
To fix this I could either redefine SEP or convert the backslashes to forward slashes. Since I now know that python uses forward slashes throughout the whole program I decided to convert the slashes. Also because the other paths would be based on the GetModuleFileName path.
Finally, after that was fixed, I got a new error that said that a module could not be loaded. Though it wasn't just one module, but rather all modules that were copied to the lib folder as a .pyd.
I double and triple checked that the modules were infact there, which they were.
The reason was that the __bootstrap__() loader couldn't find it.
def__bootstrap__():importimp,os,sysglobal__bootstrap__,__loader____loader__=None;del__bootstrap__,__loader__found=Falseforpinsys.path:ifnotos.path.isdir(p):continuef=os.path.join(p,"%s")ifnotos.path.exists(f):continuem=imp.load_dynamic(__name__,f)importsyssys.modules[__name__]=mfound=Truebreakifnotfound:delsys.modules[__name__]raiseImportError("No module named %%s"%%__name__)__bootstrap__()
This was because sys.path did not contain the ./lib folder. So I looked at the ConsoleSetLibPath.py initscript, which seemed outdated and not used for this kind of action but rather to set it to one path only?
So I kinda bruteforced the path in.
Now for the PyQt4/5 hooks. I added a few checks for the implicit includes, because I knew that they are not being used. Basically this lets me add them to the excludes list so it doesn't clutter up the final build.
Additionally, I use the mingw-w64-x86_64-qt5-5.5.0-1-any.pkg.tar.xz package, which adds additional development dlls. Such as qwindowsd.dll and Qt5Guid.dll.
Because of the hook for the imageformats and platforms which contain some dev dlls they will be imported and their dependencies will be resolved which will include the Qt5Guid.dll, Qt5Cored.dll and others with a filesize of up to 600mb.
So I added another check for such files to not include them.
Regarding the path separator converter: I don't think this will work in all cases. Sadly the macro __MINGW32__ is not set when I tried to compile it. So I don't really know how to check when to convert and when not to...