Commit cd406b9a authored by sumpfralle's avatar sumpfralle

removed code used for testing usability of Python 2.7 for PyInstaller

renamed startup file temporarily for packaging (fixes multiprocessing problems)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@970 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 93e0afb7
...@@ -3,6 +3,10 @@ BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]), ...@@ -3,6 +3,10 @@ BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]),
os.path.pardir)) os.path.pardir))
UI_DATA_RELATIVE = os.path.join("share", "ui") UI_DATA_RELATIVE = os.path.join("share", "ui")
UI_DATA_DIR = os.path.join(BASE_DIR, UI_DATA_RELATIVE) UI_DATA_DIR = os.path.join(BASE_DIR, UI_DATA_RELATIVE)
# We need to use a startup file ending with ".py" to allow forking in multiprocessing mode.
# Copy "pycam" to this file and remove it after building.
STARTUP_SCRIPT = os.path.join(BASE_DIR, "pycamGUI.py")
ORIGINAL_STARTUP_SCRIPT = os.path.join(BASE_DIR, "pycam")
data = [(os.path.join(UI_DATA_RELATIVE, "pycam-project.ui"), os.path.join(UI_DATA_DIR, "pycam-project.ui"), "DATA"), data = [(os.path.join(UI_DATA_RELATIVE, "pycam-project.ui"), os.path.join(UI_DATA_DIR, "pycam-project.ui"), "DATA"),
(os.path.join(UI_DATA_RELATIVE, "menubar.xml"), os.path.join(UI_DATA_DIR, "menubar.xml"), "DATA"), (os.path.join(UI_DATA_RELATIVE, "menubar.xml"), os.path.join(UI_DATA_DIR, "menubar.xml"), "DATA"),
...@@ -16,7 +20,7 @@ start_dirs = (os.path.join(os.environ["PROGRAMFILES"], "Common files", "Gtk"), ...@@ -16,7 +20,7 @@ start_dirs = (os.path.join(os.environ["PROGRAMFILES"], "Common files", "Gtk"),
def find_gtk_pixbuf_dir(dirs): def find_gtk_pixbuf_dir(dirs):
for start_dir in dirs: for start_dir in dirs:
for root, dirs, files in os.walk(start_dir): for root, dirs, files in os.walk(start_dir):
if "libpango-1.0-0.dll" in files: if "libpixbufloader-png.dll" in files:
return root return root
return None return None
gtk_loaders_dir = find_gtk_pixbuf_dir(start_dirs) gtk_loaders_dir = find_gtk_pixbuf_dir(start_dirs)
...@@ -53,8 +57,6 @@ glut32_dll = find_glut32(sys.prefix) ...@@ -53,8 +57,6 @@ glut32_dll = find_glut32(sys.prefix)
if glut32_dll: if glut32_dll:
more_libs.append((os.path.basename(glut32_dll), glut32_dll, "BINARY")) more_libs.append((os.path.basename(glut32_dll), glut32_dll, "BINARY"))
more_libs.append(("msjava.dll", "msjava.dll", "BINARY"))
def get_pixbuf_loaders_prefix(gtk_loaders_dir): def get_pixbuf_loaders_prefix(gtk_loaders_dir):
prefix = [] prefix = []
path_splits = gtk_loaders_dir.split(os.path.sep) path_splits = gtk_loaders_dir.split(os.path.sep)
...@@ -81,48 +83,31 @@ from pycam import VERSION ...@@ -81,48 +83,31 @@ from pycam import VERSION
samples = Tree(os.path.join(BASE_DIR, "samples"), prefix="samples") samples = Tree(os.path.join(BASE_DIR, "samples"), prefix="samples")
fonts = Tree(os.path.join(BASE_DIR, "share", "fonts"), prefix=os.path.join("share", "fonts")) fonts = Tree(os.path.join(BASE_DIR, "share", "fonts"), prefix=os.path.join("share", "fonts"))
# First we have to know where gtk is installed, we get this from registry
import _winreg
import msvcrt
try:
k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\GTK2-Runtime')
except EnvironmentError:
print 'You must install the Gtk+ 2.2 Runtime Environment to run this program'
while not msvcrt.kbhit():
pass
sys.exit(1)
else:
gtkdir = str(_winreg.QueryValueEx(k, 'InstallationDirectory')[0])
gtkversion = str(_winreg.QueryValueEx(k, 'BinVersion')[0])
# TODO: fix this hard-coded path
engines_dir = os.path.normpath("C:/Python26/Lib/site-packages/gtk-2.0/runtime/lib/gtk-2.0/2.10.0/engines")
if not os.path.isdir(engines_dir):
print "Failed to locate the engines directory: %s" % str(engines_dir)
sys.exit(1)
#Then we want to go to the directory where the gtkrcfile is located
gtkrc_dir = os.path.join('share', 'themes', 'MS-Windows', 'gtk-2.0')
if not os.path.isdir(gtkrc_dir):
gtkrc_dir = os.path.normpath("C:/Python26/Lib/site-packages/gtk-2.0/runtime/share/themes/MS-Windows/gtk-2.0")
#Add gtkrc file to exe
data.append(('gtkrc', os.path.join(gtkdir, gtkrc_dir, 'gtkrc'), 'DATA'))
#Add libwimp.dll to exe (needed for the MS-Windows theme)
more_libs.append(('libwimp.dll', os.path.join(gtkdir, engines_dir, 'libwimp.dll'), 'BINARY'))
themes = Tree(os.path.join(gtkrc_dir, os.pardir, os.pardir, os.pardir, "icons"),
prefix=os.path.join("share", "icons"))
icon_file = os.path.join(BASE_DIR, "share", "pycam.ico") icon_file = os.path.join(BASE_DIR, "share", "pycam.ico")
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), os.path.join(BASE_DIR, 'pycam'), os.path.join(BASE_DIR, "src", "use_gtk.py")], if os.path.exists(STARTUP_SCRIPT):
print "New startup script already exists: %s" % STARTUP_SCRIPT
else:
os.rename(ORIGINAL_STARTUP_SCRIPT, STARTUP_SCRIPT)
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), STARTUP_SCRIPT],
pathex=[os.path.join(BASE_DIR, "src")], pathex=[os.path.join(BASE_DIR, "src")],
hookspath=[os.path.join(BASE_DIR, "pyinstaller", "hooks")]) hookspath=[os.path.join(BASE_DIR, "pyinstaller", "hooks")])
pyz = PYZ(a.pure) pyz = PYZ(a.pure)
exe = EXE(pyz, data, samples, gtk_pixbuf_loaders, themes, fonts, # remove all ".svn" files
for file_list in (data, samples, gtk_pixbuf_loaders, fonts, a.datas):
flist_copy = list(file_list)
# clear the original list
while file_list:
file_list.pop()
# add all items that don't contain a ".svn" directory name
for fentry in flist_copy:
if not ".svn" in fentry[0].split(os.path.sep):
file_list.append(fentry)
exe = EXE(pyz, data, samples, gtk_pixbuf_loaders, fonts,
a.scripts, a.scripts,
a.binaries + more_libs, a.binaries + more_libs,
a.zipfiles, a.zipfiles,
...@@ -135,3 +120,8 @@ exe = EXE(pyz, data, samples, gtk_pixbuf_loaders, themes, fonts, ...@@ -135,3 +120,8 @@ exe = EXE(pyz, data, samples, gtk_pixbuf_loaders, themes, fonts,
console=True, console=True,
) )
if not os.path.exists(ORIGINAL_STARTUP_SCRIPT):
os.rename(STARTUP_SCRIPT, ORIGINAL_STARTUP_SCRIPT)
else:
print "Keeping original startup script: %s" % ORIGINAL_STARTUP_SCRIPT
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment