OSDN Git Service

prepare .spec file for pyinstaller2.1 & revise source
authorkei9 <kei9@users.sourceforge.jp>
Fri, 6 Dec 2013 16:48:50 +0000 (01:48 +0900)
committerkei9 <kei9@users.sourceforge.jp>
Fri, 6 Dec 2013 16:48:50 +0000 (01:48 +0900)
amulettool.py
environment.txt [new file with mode: 0644]
spec/amulettool_merged.spec [new file with mode: 0644]
spec/amulettool_splitted.spec [new file with mode: 0644]
view/gaugedialogview.py
view/mainframeview.py

index f1143ad..c94bcd2 100644 (file)
@@ -6,6 +6,7 @@
 import threading
 import time
 import os.path
 import threading
 import time
 import os.path
+import sys
 import pickle
 import sqlite3
 
 import pickle
 import sqlite3
 
@@ -18,11 +19,21 @@ SETTING_FILE = u"settings"
 SETTING_THRESHOLD = u"threshold"
 SETTING_SKILLS = u"skills"
 
 SETTING_THRESHOLD = u"threshold"
 SETTING_SKILLS = u"skills"
 
+def _get_base_dir():
+    u""" for pyinstaller 2.1 """
+    if getattr(sys, 'frozen', False):
+        # we are running in a |PyInstaller| bundle
+        basedir = sys._MEIPASS
+    else:
+        # we are running in a normal Python environment
+        basedir = os.path.dirname(__file__)
+    return basedir
+
 class AmuletToolController(wx.App):
     u""" アプリケーションの制御クラス """
     def OnInit(self):
         self._read_settings()
 class AmuletToolController(wx.App):
     u""" アプリケーションの制御クラス """
     def OnInit(self):
         self._read_settings()
-        self.frame_view = view.MainFrameView("view")
+        self.frame_view = view.MainFrameView(os.path.join(_get_base_dir(), "view", view.XRC_MAIN_FRAME))
 
         self._init_events()
 
 
         self._init_events()
 
@@ -76,7 +87,7 @@ class AmuletToolController(wx.App):
                 generator = model.DataBaseGenerator(model.DB_FILE_NAME)
                 #generator = model.DataBaseGenerator()
 
                 generator = model.DataBaseGenerator(model.DB_FILE_NAME)
                 #generator = model.DataBaseGenerator()
 
-                dlg_view = view.GaugeDialogView("view")
+                dlg_view = view.GaugeDialogView(os.path.join(_get_base_dir(), "view", view.XRC_GAUGE_DIALOG))
                 def _loop():
                     while t1.is_alive():
                         dlg_view.gauge.Pulse()
                 def _loop():
                     while t1.is_alive():
                         dlg_view.gauge.Pulse()
diff --git a/environment.txt b/environment.txt
new file mode 100644 (file)
index 0000000..d3c959a
--- /dev/null
@@ -0,0 +1,4 @@
+--- environment ---
+python 2.7.5 for windows (64bit)
+wxpython 2.8.12 for python 2.7.x (win64, unicode)
+pyinstaller 2.1
diff --git a/spec/amulettool_merged.spec b/spec/amulettool_merged.spec
new file mode 100644 (file)
index 0000000..1846556
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- mode: python -*-
+a = Analysis(['d:\\Git\\AmuletToolsMH4\\amulettool.py'],
+             pathex=['D:\\MyHome\\Tools\\programming\\PyInstaller-2.1\\amulettool'],
+             hiddenimports=[],
+             hookspath=None,
+             runtime_hooks=None)
+a.datas += [("view/mainframe.xrc", "d:\\Git\\AmuletToolsMH4\\view\\mainframe.xrc", "DATA")]
+a.datas += [("view/gaugedialog.xrc", "d:\\Git\\AmuletToolsMH4\\view\\gaugedialog.xrc", "DATA")]
+pyz = PYZ(a.pure)
+exe = EXE(pyz,
+          a.scripts,
+          a.binaries,
+          a.zipfiles,
+          a.datas,
+          name='amulettool.exe',
+          debug=False,
+          strip=None,
+          upx=True,
+          console=False )
diff --git a/spec/amulettool_splitted.spec b/spec/amulettool_splitted.spec
new file mode 100644 (file)
index 0000000..dc4cc8f
--- /dev/null
@@ -0,0 +1,24 @@
+# -*- mode: python -*-
+a = Analysis(['d:\\Git\\AmuletToolsMH4\\amulettool.py'],
+             pathex=['D:\\MyHome\\Tools\\programming\\PyInstaller-2.1\\amulettool'],
+             hiddenimports=[],
+             hookspath=None,
+             runtime_hooks=None)
+a.datas += [("view/gaugedialog.xrc", "D:\\Git\\AmuletToolsMH4\\view\\gaugedialog.xrc", "DATA"),
+          ("view/mainframe.xrc", "D:\\Git\\AmuletToolsMH4\\view\\mainframe.xrc", "DATA")]
+pyz = PYZ(a.pure)
+exe = EXE(pyz,
+          a.scripts,
+          exclude_binaries=True,
+          name='amulettool.exe',
+          debug=False,
+          strip=None,
+          upx=True,
+          console=True )
+coll = COLLECT(exe,
+               a.binaries,
+               a.zipfiles,
+               a.datas,
+               strip=None,
+               upx=True,
+               name='amulettool')
index c092f67..3aec35b 100644 (file)
@@ -3,18 +3,14 @@
 # 進行状況をゲージで示すダイアログ
 # 2013/12/05 written by kei9
 import wx
 # 進行状況をゲージで示すダイアログ
 # 2013/12/05 written by kei9
 import wx
-import os.path
 from wx import xrc
 
 import constnumbers
 
 class GaugeDialogView():
     u""" メインのフレームクラス """
 from wx import xrc
 
 import constnumbers
 
 class GaugeDialogView():
     u""" メインのフレームクラス """
-    def __init__(self, dirname=None):
-        if dirname is None:
-            self.res = wx.xrc.XmlResource(constnumbers.XRC_GAUGE_DIALOG)
-        else:
-            self.res = wx.xrc.XmlResource(os.path.join(dirname,constnumbers.XRC_GAUGE_DIALOG))
+    def __init__(self, filename):
+        self.res = wx.xrc.XmlResource(filename)
         self._init_dialog()
 
     def _init_dialog(self):
         self._init_dialog()
 
     def _init_dialog(self):
index 43eee6e..a90011c 100644 (file)
@@ -2,8 +2,6 @@
 
 # GUIのメインフレーム
 # 2013/12/05 written by kei9
 
 # GUIのメインフレーム
 # 2013/12/05 written by kei9
-import os.path
-
 import wx
 from wx import xrc
 import wx.lib.intctrl
 import wx
 from wx import xrc
 import wx.lib.intctrl
@@ -12,11 +10,8 @@ import constnumbers
 
 class MainFrameView():
     u""" メインのフレームクラス """
 
 class MainFrameView():
     u""" メインのフレームクラス """
-    def __init__(self, dirname=None):
-        if dirname is None:
-            self.res = wx.xrc.XmlResource(constnumbers.XRC_MAIN_FRAME)
-        else:
-            self.res = wx.xrc.XmlResource(os.path.join(dirname,constnumbers.XRC_MAIN_FRAME))
+    def __init__(self, filename):
+        self.res = wx.xrc.XmlResource(filename)
         self._init_frame()
 
     def _init_frame(self):
         self._init_frame()
 
     def _init_frame(self):