Commit cb45aaf7 authored by sumpfralle's avatar sumpfralle

fixed pyinstaller standalone generation

updated version to 0.4

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@792 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent ac48ae81
......@@ -27,6 +27,11 @@ import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
# register the glut32.dll manually for the pyinstaller standalone executable
if hasattr(sys, "frozen") and sys.frozen and "_MEIPASS2" in os.environ:
from ctypes import windll
windll[os.path.join(os.environ["_MEIPASS2"], "glut32.dll")]
from pycam.Physics.ode_physics import override_ode_availability
import pycam.Gui.common as GuiCommon
import pycam.Gui.Settings
......
# -*- mode: python -*-
BASE_DIR = os.getcwd()
a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), os.path.join(BASE_DIR, 'pycam')],
pathex=[os.path.join(BASE_DIR, "src")],
hookspath=[os.path.join(BASE_DIR, "pyinstaller", "hooks")])
pyz = PYZ(a.pure)
BASE_DIR = os.path.realpath(os.path.join(os.path.dirname(locals()["spec"]),
os.path.pardir))
data = [("pycam-project.ui", os.path.join(BASE_DIR, "share", "gtk-interface", "pycam-project.ui"), "DATA"),
("menubar.xml", os.path.join(BASE_DIR, "share", "gtk-interface", "menubar.xml"), "DATA"),
("logo_gui.bmp", os.path.join(BASE_DIR, "share", "gtk-interface", "logo_gui.bmp"), "DATA"),
("logo_gui.png", os.path.join(BASE_DIR, "share", "gtk-interface", "logo_gui.png"), "DATA"),
]
start_dirs = (os.path.join(os.environ["PROGRAMFILES"], "Common files", "Gtk"),
os.path.join(os.environ["COMMONPROGRAMFILES"], "Gtk"))
def find_gtk_pixbuf_dir(dirs):
for start_dir in dirs:
for root, dirs, files in os.walk(start_dir):
if "libpixbufloader-png.dll" in files:
return root
return None
gtk_loaders_dir = find_gtk_pixbuf_dir(start_dirs)
if gtk_loaders_dir is None:
print >>sys.stderr, "Failed to locate Gtk installation (looking for libpixbufloader-png.dll)"
sys.exit(1)
config_dir = gtk_loaders_dir
config_relative = os.path.join("etc", "gtk-2.0", "gdk-pixbuf.loaders")
while not os.path.isfile(os.path.join(config_dir, config_relative)):
config_dir = os.path.dirname(config_dir)
if not config_dir:
print >>sys.stderr, "Failed to locate '%s' around '%s'" \
% (config_relative, gtk_loaders_dir)
gtk_pixbuf_config_file = os.path.join(config_dir, config_relative)
data.append((config_relative, os.path.join(config_dir, config_relative), "DATA"))
# somehow we need to add glut32.dll manually
more_libs = []
glut32_dll = os.path.join(config_dir, "bin", "glut32.dll")
more_libs.append((os.path.basename(glut32_dll), glut32_dll, "BINARY"))
def get_pixbuf_loaders_prefix(gtk_loaders_dir):
prefix = []
path_splits = gtk_loaders_dir.split(os.path.sep)
while path_splits and (not prefix or (prefix[-1].lower() != "lib")):
prefix.append(path_splits.pop())
if prefix[-1].lower() == "lib":
prefix.reverse()
return "\\".join(prefix)
return os.path.join(*prefix)
else:
return None
gtk_pixbuf_loaders_prefix = get_pixbuf_loaders_prefix(gtk_loaders_dir)
if gtk_pixbuf_loaders_prefix is None:
print >>sys.stderr, "Failed to extract the prefix from '%s'" % gtk_loaders_dir
sys.exit(1)
gtk_pixbuf_loaders = Tree(gtk_loaders_dir, prefix=gtk_pixbuf_loaders_prefix)
# import VERSION for the output filename
sys.path.insert(0, os.path.join(BASE_DIR, "src"))
from pycam import VERSION
samples = Tree(os.path.join(BASE_DIR, "samples"), prefix="samples")
exe = EXE(pyz, data, samples,
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')],
pathex=[os.path.join(BASE_DIR, "src")],
hookspath=[os.path.join(BASE_DIR, "pyinstaller", "hooks")])
pyz = PYZ(a.pure)
exe = EXE(pyz, data, samples, gtk_pixbuf_loaders,
a.scripts,
a.binaries,
a.binaries + more_libs,
a.zipfiles,
a.datas,
name=os.path.join(BASE_DIR, "pycam-%s_standalone.exe" % VERSION),
icon=icon_file,
debug=False,
strip=False,
upx=True,
console=True )
console=True,
)
......@@ -56,11 +56,12 @@ DATA_DIR_ENVIRON_KEY = "PYCAM_DATA_DIR"
DATA_BASE_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
os.pardir, "share", "gtk-interface"),
os.path.join(sys.prefix, "share", "pycam", "ui")]
if DATA_DIR_ENVIRON_KEY in os.environ:
DATA_BASE_DIRS.insert(0, os.environ[DATA_DIR_ENVIRON_KEY])
# necessary for "pyinstaller"
if "_MEIPASS2" in os.environ:
DATA_BASE_DIRS.insert(0, os.environ["_MEIPASS2"])
# respect an override via an environment setting
if DATA_DIR_ENVIRON_KEY in os.environ:
DATA_BASE_DIRS.insert(0, os.environ[DATA_DIR_ENVIRON_KEY])
GTKBUILD_FILE = "pycam-project.ui"
GTKMENU_FILE = "menubar.xml"
......@@ -757,7 +758,7 @@ class ProjectGui:
recent_files_menu.connect("item-activated",
self.load_recent_model_file)
else:
self.gui.get_object("OpenRecentModel").hide()
self.gui.get_object("OpenRecentModel").set_visible(False)
# load the menubar and connect functions to its items
self.menubar = uimanager.get_widget("/MenuBar")
window_box = self.gui.get_object("WindowBox")
......
......@@ -22,5 +22,5 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
__all__=["Cutters","Exporters","Geometry","Gui","Importers","PathGenerators","PathProcessors","Utils"]
VERSION = "0.3"
VERSION = "0.4"
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