OSDN Git Service

add make.py for pyinstaller
authorkei9 <kei9@users.sourceforge.jp>
Sat, 7 Dec 2013 08:15:05 +0000 (17:15 +0900)
committerkei9 <kei9@users.sourceforge.jp>
Sat, 7 Dec 2013 08:15:05 +0000 (17:15 +0900)
.gitignore
AmuletToolsMH4.spec [new file with mode: 0644]
environment.txt
make.py [new file with mode: 0644]
readme.txt [new file with mode: 0644]
spec/amulettool.spec [moved from spec/amulettool_merged.spec with 79% similarity]
spec/amulettool_splitted.spec [deleted file]
spec/readme.txt [new file with mode: 0644]

index 543e624..ea68b13 100644 (file)
@@ -3,3 +3,6 @@
 *.sqlite3
 *.bak
 settings
+build/
+dist/
+archive/
diff --git a/AmuletToolsMH4.spec b/AmuletToolsMH4.spec
new file mode 100644 (file)
index 0000000..0d7b852
--- /dev/null
@@ -0,0 +1,19 @@
+# -*- mode: python -*-
+a = Analysis(['amulettool.py'],
+             pathex=['D:\\Git\\AmuletToolsMH4'],
+             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='AmuletToolsMH4.exe',
+          debug=False,
+          strip=None,
+          upx=True,
+          console=False )
index d3c959a..8a2468c 100644 (file)
@@ -1,4 +1,14 @@
 --- environment ---
 python 2.7.5 for windows (64bit)
-wxpython 2.8.12 for python 2.7.x (win64, unicode)
+wxpython 2.8.12 for python 2.7.x (win32, unicode)
 pyinstaller 2.1
+
+--- license ---
+wxpython: wxwidgets\82É\8f\80\82¸\82é
+wxwidigets: wxwindows license
+       LGPL2\82Ü\82½\82Í\82»\82ê\88È\8d~\82É\97á\8aO\8fð\8d\80\82ð\89Á\82¦\82½\82à\82Ì
+       http://www.wxwidgets.org/about/newlicen.htm
+
+pyinstaller:
+       pyinstaller\82ÍGPL\82É\97á\8aO\82ð\89Á\82¦\82½\82à\82Ì\82Æ\82È\82é
+       pyinstaller\82Å\90\90¬\82³\82ê\82½\83o\83C\83i\83\8a\82Í\82¢\82¸\82ê\82Ì\83\89\83C\83Z\83\93\83X\82Å\82Ì\94z\95z\82à\89Â\94\
diff --git a/make.py b/make.py
new file mode 100644 (file)
index 0000000..23579e4
--- /dev/null
+++ b/make.py
@@ -0,0 +1,65 @@
+# -*- coding:utf-8 -*-
+
+# generate pyinstaller's spec file & modify .spec file
+# 2013/12/07 written by kei9
+
+import subprocess
+import tempfile
+import os
+import os.path
+import shutil
+
+BUNDLE_RESOURCES = [(r"view/mainframe.xrc", r"d:\\Git\\AmuletToolsMH4\\view\\mainframe.xrc"),
+       (r"view/gaugedialog.xrc", r"d:\\Git\\AmuletToolsMH4\\view\\gaugedialog.xrc")]
+MOVE_FILES = ["data.zip", "readme.txt"]
+
+
+SCRIPTFILE = "amulettool.py"
+APPNAME = "AmuletToolsMH4"
+
+MAKESPEC = "pyi-makespec"
+PYINSTALLER = "pyinstaller"
+
+SPECOPTIONS = ["--onefile", "--windowed", "--name=" + APPNAME]
+
+def get_insert_lines():
+    result = []
+    for item in BUNDLE_RESOURCES:
+        result.append(r'a.datas += [("{0}", "{1}", "DATA")]'.format(item[0], item[1]) + "\n")
+    return result
+
+if __name__ == "__main__":
+    cmd = [MAKESPEC] + SPECOPTIONS + [SCRIPTFILE]
+    print " ".join(cmd)
+    out = subprocess.check_output(cmd)
+    print out
+
+    # insert bundle data line to .spec
+    print "insert bundle resources to .spec file"
+    specfile = APPNAME + ".spec"
+    with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
+        tmpname = tmp_file.name
+        with open(specfile, "r") as f:
+            for line in f:
+                if line.startswith("pyz"):
+                    for l in get_insert_lines():
+                        tmp_file.write(l)
+                tmp_file.write(line)
+
+    os.remove(specfile)
+    os.rename(tmpname, specfile)
+
+    # conduct pyinstall
+    cmd = [PYINSTALLER, specfile]
+    print " ".join(cmd)
+    out = subprocess.check_output(cmd)
+    print out
+
+    # copy file to dist 
+    file_dir = os.path.dirname(os.path.abspath(__file__))
+    for f in MOVE_FILES:
+        abs_path = os.path.abspath(f)
+        relative_path = os.path.relpath(abs_path, file_dir)
+        shutil.copy(abs_path, os.path.join("dist", relative_path))
+
+    print "Finished"
diff --git a/readme.txt b/readme.txt
new file mode 100644 (file)
index 0000000..e69de29
similarity index 79%
rename from spec/amulettool_merged.spec
rename to spec/amulettool.spec
index 1846556..5274fab 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: python -*-
-a = Analysis(['d:\\Git\\AmuletToolsMH4\\amulettool.py'],
-             pathex=['D:\\MyHome\\Tools\\programming\\PyInstaller-2.1\\amulettool'],
+a = Analysis(['amulettool.py'],
+             pathex=['D:\\Git\\AmuletToolsMH4'],
              hiddenimports=[],
              hookspath=None,
              runtime_hooks=None)
diff --git a/spec/amulettool_splitted.spec b/spec/amulettool_splitted.spec
deleted file mode 100644 (file)
index dc4cc8f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- 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')
diff --git a/spec/readme.txt b/spec/readme.txt
new file mode 100644 (file)
index 0000000..fa9c142
--- /dev/null
@@ -0,0 +1,26 @@
+pyinstaller2.1\97p\82Ì.spec\83t\83@\83C\83\8b
+>pyi-makespec --onefile --windowed amulettool.py
+\82Å\90\90¬\82³\82ê\82½.spec\83t\83@\83C\83\8b\82É\82¨\82¢\82Ä\81A
+
+\81E\8e©\93®\90\90¬
+---------------------------------------------------------------------
+a = Analysis([...], ...)
+pyz = PYZ(a.pure)
+exe = EXE(...)
+---------------------------------------------------------------------
+
+\82Æ\82È\82Á\82Ä\82¢\82é\83t\83@\83C\83\8b\82É\91Î\82µ\82Ä\81A
+"a=Analysis()"\82Ì\8ds\82Æ"pyz = PYZ()"\82Ì\8ds\82Ì\8aÔ\82É\81A
+exe\82É\92Ç\89Á\82·\82é\83\8a\83\\81[\83X\83t\83@\83C\83\8b\82Æ\82µ\82Ä\88È\89º\82Ì2\8ds\82ð\91}\93ü\82µ\82Ä\82¢\82é
+a.datas += [("view/mainframe.xrc", "d:\\Git\\AmuletToolsMH4\\view\\mainframe.xrc", "DATA")]
+a.datas += [("view/gaugedialog.xrc", "d:\\Git\\AmuletToolsMH4\\view\\gaugedialog.xrc", "DATA")]
+
+\81E\95Ï\8dX\8cã
+---------------------------------------------------------------------
+a = Analysis([...], ...)
+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(...)
+---------------------------------------------------------------------
+