Commit 6caf64e4 authored by sumpfralle's avatar sumpfralle

added a pyinstaller spec file for creating standalone binaries for Windows

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@627 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0169a353
......@@ -42,10 +42,13 @@ import time
log = pycam.Utils.log.get_logger()
EXAMPLE_MODEL_LOCATIONS = (
EXAMPLE_MODEL_LOCATIONS = [
os.path.join(os.path.dirname(__file__), "samples"),
os.path.join(sys.prefix, "share", "pycam", "samples"),
os.path.join("usr", "share", "pycam", "samples"))
os.path.join("usr", "share", "pycam", "samples")]
# for pyinstaller (windows distribution)
if "_MEIPASS2" in os.environ:
EXAMPLE_MODEL_LOCATIONS.insert(0, os.path.join(os.environ["_MEIPASS2"], "samples"))
DEFAULT_MODEL_FILE = "pycam.stl"
EXIT_CODES = {"ok": 0, "requirements": 1, "load_model_failed": 2,
"write_output_failed": 3, "parsing_failed": 4}
......
# keysyms does not seem to be recognized by pyinstaller
# There will be exceptions after any keypress without this line.
hiddenimports = ["gtk.keysyms"]
\ No newline at end of file
# -*- 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)
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"),
]
# 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,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join(BASE_DIR, "pycam-%s_standalone.exe" % VERSION),
debug=False,
strip=False,
upx=True,
console=True )
PyInstaller (http://pyinstaller.org) can be used to create standalone binaries for Windows.
How to build a standalone exe file (on Windows only):
1) download pyinstaller
2) run "cmd"
3) "cd PATH_TO_PYCAM"
4) "python PYINSTALLER_PATH\Build.py pyinstaller\pycam.spec"
5) test and upload the binary file "pycam-VERSION_standalone.exe"
Known issues:
- the "logo_gui.png" image is not displayed in the "Preferences" window
(the dll for png support is not included; the "pixbuf.loaders" file does not exist)
......@@ -54,6 +54,9 @@ DATA_BASE_DIRS = [os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
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"])
GTKBUILD_FILE = "pycam-project.ui"
GTKMENU_FILE = "menubar.xml"
......@@ -843,6 +846,8 @@ class ProjectGui:
max_distance = self.settings.get("support_grid_distance_y")
# we allow an individual adjustment of 66% of the distance
max_distance /= 1.5
if hasattr(self.grid_adjustment_value, "set_lower"):
# gtk 2.14 is required for "set_lower" and "set_upper"
self.grid_adjustment_value.set_lower(-max_distance)
self.grid_adjustment_value.set_upper(max_distance)
if self.grid_adjustment_value.get_value() \
......
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