For 32bit:
2. Open above file with 7zip, Extract "gcc4" to C: then rename "C:\gcc4" to "C:\mingw"
3. Go to C:\mingw\bin rename all i686-w64-mingw32-.exe to mingw32-.exe
4. Inside command prompt where you will invoke nuitka, type the following
SET CXXFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET CFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET LDFLAGS=-vcr100
note: "-vcr100" is for python 3.4-3.5, For older python use "-vcr90"
For 64bit:
2. Open above file with 7zip, Extract "gcc64seh" to C: then rename "C:\gcc64seh" to "C:\mingw"
3. Go to C:\mingw\bin copy gcc.exe and g++.exe into x86_64-w64-mingw32-gcc.exe and x86_64-w64-mingw32-g++.exe respectively.
4. Inside command prompt where you will invoke nuitka, type the following
SET CXXFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET CFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET LDFLAGS=-vcr100 -Wl,--large-address-aware
note: "-vcr100" is for python 3.4-3.5, For older python use "-vcr90"
nuitka:
1. Invoke nuitka as: nuitka --standalone [your_main_app].py
2. Hopefully executable produced in [your_main_app].dist directory
3. Due to the nature of typelib and gnome runtime modularity, nuitka unable to resolve all dependecies, so the following need manual copying: [site-packages]\gnome* -> [your_main_app].dist\
note: in most case you can exclude all [site-packages]\gnome*.exe except dbus-daemon.exe (if you use DBus) or gspawner.exe if you need those
4. Test your app, if it works you can rebuild with: nuitka --windows-disable-console --windows-icon=[icon_file] --standalone [your_main_app].py
and repeat step 3
5. If you build for python 2.7-3.2 you will need to employ Microsoft.VC90.CRT trick if you don't want to install MSVCRT2008 Runtime as part of your installer or asking your users to install it themselves.
Above steps are tested on gtk-demo.py (from pygobject source repo), your app's (missing) depedencies maybe a lot more than that.
Hi. It may be a bit late for this response, but I had a similar issue freezing a PyGI app using PyInstaller. (See issue #44 in this site for details.)
In a nutshell, the PyGI app could be frozen and executed just fine with a stock PyGI example program from the Gnome website, but when I imported the Pango module and used the 'pygtkcompat' compatibility layer, it failed to find some missing typelib files when I tried to launch the executable. The solution was to include those typelibs explicitly in the PyInstaller executable.
I've enclosed the example Python app and the PyInstaller .spec file that successfully solved my problem. See the 'binaries' list in the .spec file.
Hope this helps anyone else using PyInstaller with Pango and pygtkcompat...
EDIT: May need to remove the 'pathex' keyword parameter from the .spec file to work in your filesystem.
Hi, I have also meet the same problem on Windows with pygi-aio-3.14.0_rev22-setup and python 2.7.
I tried to follow the instructions @tumagonx gives out.
I have copied files in gnome, cairo, pygtkcompact and gi directory into the XXX.dist directory.
However it still report "cannot import name Gtk", even after i copied the "rpath.pth" file in.
Due to the path of gnome is added by "rpath.pth" file in site-packages directory in Python distribution, I suspect that nuitka have difficulty on that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello !
I try to freeze an app with pygi for windows users but it fails... :-(
I tried with nuitka (my preferred tool to freeze) and it doesn't work (see : http://bugs.nuitka.net/issue242).
I tried also with pyinstaller and cx_freeze but it fails too...
Does somebody have a protocol to freeze with success an app using pygi on windows ? I must forgot something...
Thanks in advance !
Alfazaz
For packaging purpose, make sure when you install pygi, only choose libraries that required by your app.
Preparing Compiler (For bundler that requiring compiler such Nuitka)
For 32bit:
2. Open above file with 7zip, Extract "gcc4" to C: then rename "C:\gcc4" to "C:\mingw"
3. Go to C:\mingw\bin rename all i686-w64-mingw32-.exe to mingw32-.exe
4. Inside command prompt where you will invoke nuitka, type the following
SET CXXFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET CFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET LDFLAGS=-vcr100
note: "-vcr100" is for python 3.4-3.5, For older python use "-vcr90"
For 64bit:
2. Open above file with 7zip, Extract "gcc64seh" to C: then rename "C:\gcc64seh" to "C:\mingw"
3. Go to C:\mingw\bin copy gcc.exe and g++.exe into x86_64-w64-mingw32-gcc.exe and x86_64-w64-mingw32-g++.exe respectively.
4. Inside command prompt where you will invoke nuitka, type the following
SET CXXFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET CFLAGS=-vcr100 -O2 -D_FILE_OFFSET_BITS=64
SET LDFLAGS=-vcr100 -Wl,--large-address-aware
note: "-vcr100" is for python 3.4-3.5, For older python use "-vcr90"
nuitka:
1. Invoke nuitka as: nuitka --standalone [your_main_app].py
2. Hopefully executable produced in [your_main_app].dist directory
3. Due to the nature of typelib and gnome runtime modularity, nuitka unable to resolve all dependecies, so the following need manual copying:
[site-packages]\gnome* -> [your_main_app].dist\
[site-packages]\cairo -> [your_main_app].dist\
[site-packages]\gi -> [your_main_app].dist\
[site-packages]\pygtkcompat -> [your_main_app].dist\
[pythonXY]\DLLs\ _ctypes.pyd -> [your_main_app].dist\
note: in most case you can exclude all [site-packages]\gnome*.exe except dbus-daemon.exe (if you use DBus) or gspawner.exe if you need those
4. Test your app, if it works you can rebuild with: nuitka --windows-disable-console --windows-icon=[icon_file] --standalone [your_main_app].py
and repeat step 3
5. If you build for python 2.7-3.2 you will need to employ Microsoft.VC90.CRT trick if you don't want to install MSVCRT2008 Runtime as part of your installer or asking your users to install it themselves.
Above steps are tested on gtk-demo.py (from pygobject source repo), your app's (missing) depedencies maybe a lot more than that.
cx_freeze:
It seems a bit older guide available at https://wiki.gnome.org/action/show/Projects/PyGObject?action=show&redirect=PyGObject#Building_on_Win32_with_cx_freeze
py2exe:
need help!
pyinstaller:
need help!
bbfreeze:
need help!
Last edit: tumagonx 2015-09-10
Thanks for your help ! My frozen program works now !!!!
I copied numerous files like you said... I think that some of them are not needed but the hardest is done. Ouf !
Hi. It may be a bit late for this response, but I had a similar issue freezing a PyGI app using PyInstaller. (See issue #44 in this site for details.)
In a nutshell, the PyGI app could be frozen and executed just fine with a stock PyGI example program from the Gnome website, but when I imported the Pango module and used the 'pygtkcompat' compatibility layer, it failed to find some missing typelib files when I tried to launch the executable. The solution was to include those typelibs explicitly in the PyInstaller executable.
I've enclosed the example Python app and the PyInstaller .spec file that successfully solved my problem. See the 'binaries' list in the .spec file.
Hope this helps anyone else using PyInstaller with Pango and pygtkcompat...
EDIT: May need to remove the 'pathex' keyword parameter from the .spec file to work in your filesystem.
Last edit: cinchent 2016-05-14
Hi, I have also meet the same problem on Windows with pygi-aio-3.14.0_rev22-setup and python 2.7.
I tried to follow the instructions @tumagonx gives out.
I have copied files in gnome, cairo, pygtkcompact and gi directory into the XXX.dist directory.
However it still report "cannot import name Gtk", even after i copied the "rpath.pth" file in.
Due to the path of gnome is added by "rpath.pth" file in site-packages directory in Python distribution, I suspect that nuitka have difficulty on that.