I have a small py program using py27 and pygtk. I can freeze this pretty happily with cx_freeze.
I am trying to βmigrateβ it to py33 and pygobject. This was pretty successful, and I am not trying to adapt my setup.py cx_freeze script to freeze the application now.
I can freeze a test application, but when I try to use my modified version, I get ImportError. What I did was that I made all the binary data in a subdirectory (bin) to try to keep the root a little less invisible.
As already mentioned, this works great with py27 and pygtk.
I shortened it to a simple py and set it to demonstrate this:
TEST.py
import os
import sys
if getattr(sys,'frozen',False):
sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin'))
sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin\\etc'))
sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin\\lib'))
sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin\\share'))
sys.path.append(os.path.join(os.path.dirname(sys.executable),'bin\\library.zip'))
os.environ['TCL_LIBRARY'] = os.path.join(os.path.dirname(sys.executable),'bin\\tcl')
os.environ['TK_LIBRARY'] = os.path.join(os.path.dirname(sys.executable),'bin\\tk')
os.environ['MATPLOTLIBDATA'] = os.path.join(os.path.dirname(sys.executable),'bin\\mpl-data')
import gi
import gi.repository
from gi.repository import Gtk
setup.py
from cx_Freeze import setup, Executable
import sys
import site
import os
site_dir = site.getsitepackages()[1]
include_dll_path = os.path.join(site_dir, "gnome")
missing_dll = ['libgtk-3-0.dll',
'libgdk-3-0.dll',
'libatk-1.0-0.dll',
'libcairo-gobject-2.dll',
'libgdk_pixbuf-2.0-0.dll',
'libjpeg-8.dll',
'libpango-1.0-0.dll',
'libpangocairo-1.0-0.dll',
'libpangoft2-1.0-0.dll',
'libpangowin32-1.0-0.dll',
'libgnutls-26.dll',
]
gtk_libs = ['etc', 'lib', 'share']
include_files = []
for dll in missing_dll:
include_files.append((os.path.join(include_dll_path, dll), dll))
for lib in gtk_libs:
include_files.append((os.path.join(include_dll_path, lib), lib))
includes = ['gi']
excludes = ['wx','email','pydoc_data','curses']
packages = ['gi']
sys.path.append(os.path.join(os.path.dirname(__file__), '.', 'bin'))
EXE1 = Executable(
script = "test.py",
initScript = None,
base = 'Console',
targetDir = "dist",
targetName = "test.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = True,
appendScriptToLibrary = False,
)
setup(
version = "9999",
description = "test",
author = "jrb",
name = "test",
options = {"build_exe": {"includes": includes,
"excludes": excludes,
"packages": packages,
'include_files':include_files,
"path": sys.path,
'append_script_to_exe':False,
'build_exe':"dist/bin",
'compressed':True,
'copy_dependent_files':True,
'create_shared_zip':True,
'include_in_shared_zip':True,
'optimize':2,
}
},
executables = [EXE1]
)
, :/c/Python33/python -OO setup.py build
dist/test.exe :
: root: - typelib Gtk
Traceback ( ): "c:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", 27, exec (, . dict) "test.py", 19,
ImportError: Gtk
typelib , - python gi . , girepository, .
?