Skip to content

Commit 786b41a

Browse files
committed
portable zip build
1 parent 758fb9f commit 786b41a

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

dist/windows/m64py.iss.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ Source: "m64py\AUTHORS"; DestDir: "{app}";
3434
Source: "m64py\COPYING"; DestDir: "{app}";
3535
Source: "m64py\README.md"; DestDir: "{app}";
3636
Source: "m64py\ChangeLog"; DestDir: "{app}";
37-
Source: "m64py\*.v64"; DestDir: "{app}\test";
38-
Source: "m64py\qt5_plugins\platforms\*.dll"; DestDir: "{app}\qt5_plugins\platforms";
37+
Source: "m64py\*.v64"; DestDir: "{app}";
38+
Source: "m64py\qt5_plugins\platforms\qwindows.dll"; DestDir: "{app}\qt5_plugins\platforms";
39+
Source: "m64py\qt5_plugins\imageformats\qsvg.dll"; DestDir: "{app}\qt5_plugins\imageformats";
3940
Source: "m64py\doc\*"; DestDir: "{app}\doc";
4041

4142
[Icons]

dist/windows/m64py.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from os.path import join
44
DIST_DIR = os.environ["DIST_DIR"]
55
BASE_DIR = os.environ["BASE_DIR"]
66

7-
a = Analysis([join(BASE_DIR, 'm64py')], pathex=[join(BASE_DIR, 'src')])
7+
a = Analysis([join(BASE_DIR, 'm64py')], hiddenimports=['pickle', 'PyQt5.Qt'], pathex=[join(BASE_DIR, 'src')])
88

99
pyz = PYZ(a.pure)
1010

setup.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import sys
5+
import glob
56
import urllib
67
import shutil
78
import zipfile
@@ -112,7 +113,7 @@ def copy_files(self):
112113
shutil.copy(join(rar_dir, "license.txt"), join(dest_path, "doc", "unrar-license.txt"))
113114
for file_name in ["AUTHORS", "ChangeLog", "COPYING", "LICENSES", "README.md"]:
114115
shutil.copy(join(BASE_DIR, file_name), dest_path)
115-
116+
116117
import PyQt5
117118
qt5_dir = dirname(PyQt5.__file__)
118119
qwindows = join(qt5_dir, "plugins", "platforms", "qwindows.dll")
@@ -123,8 +124,10 @@ def copy_files(self):
123124

124125
def remove_files(self):
125126
dest_path = join(self.dist_dir, "m64py")
126-
for dir_name in ["api", "include", "man6"]:
127+
for dir_name in ["api", "include", "man6", "applications", "apps"]:
127128
shutil.rmtree(join(dest_path, dir_name))
129+
for file_name in glob.glob(join(dest_path, "icu*.dll")):
130+
os.remove(file_name)
128131

129132
def run_build_installer(self):
130133
iss_file = ""
@@ -146,7 +149,7 @@ def run_build(self):
146149
spec_file = join(self.dist_dir, "m64py.spec")
147150
os.environ["BASE_DIR"] = BASE_DIR
148151
os.environ["DIST_DIR"] = self.dist_dir
149-
opts = {"distpath": self.dist_dir, "workpath": work_path, "clean_build": True, "upx_dir": None}
152+
opts = {"distpath": self.dist_dir, "workpath": work_path, "clean_build": True, "upx_dir": None, "debug": False}
150153
PyInstaller.build.main(None, spec_file, True, **opts)
151154

152155
def run(self):
@@ -160,6 +163,47 @@ def run(self):
160163
self.run_build_installer()
161164

162165

166+
class build_zip(build_exe):
167+
168+
def run_build_zip(self):
169+
os.rename(join(self.dist_dir, "m64py"), join(self.dist_dir, "m64py-%s" % FRONTEND_VERSION))
170+
shutil.make_archive(join(self.dist_dir, "m64py-%s-portable" % FRONTEND_VERSION),
171+
"zip", self.dist_dir, "m64py-%s" % FRONTEND_VERSION, True)
172+
173+
def set_config_path(self):
174+
core_file = ""
175+
core_path = join(BASE_DIR, "src", "m64py", "core", "core.py")
176+
with open(core_path, "r") as core: data = core.read()
177+
lines = data.split("\n")
178+
for line in lines:
179+
if "C.c_int(CORE_API_VERSION)" in line:
180+
line = line.replace("None", "C.c_char_p(os.getcwd().encode())")
181+
core_file += line + "\n"
182+
with open(core_path, "w") as core: core.write(core_file)
183+
184+
settings_file = ""
185+
settings_path = join(BASE_DIR, "src", "m64py", "frontend", "settings.py")
186+
with open(settings_path, "r") as core: data = core.read()
187+
lines = data.split("\n")
188+
for line in lines:
189+
if "QSettings(" in line:
190+
line = line.replace('QSettings("m64py", "m64py")',
191+
'QSettings(os.path.join(os.getcwd(), "m64py.ini"), QSettings.IniFormat)')
192+
settings_file += line + "\n"
193+
with open(settings_path, "w") as core: core.write(settings_file)
194+
195+
def run(self):
196+
self.run_command("build_qt")
197+
set_sdl2()
198+
set_rthook()
199+
self.set_config_path()
200+
self.run_build()
201+
self.copy_emulator()
202+
self.copy_files()
203+
self.remove_files()
204+
self.run_build_zip()
205+
206+
163207
class build_dmg(Command):
164208
user_options = []
165209
dist_dir = join(BASE_DIR, "dist", "macosx")
@@ -253,7 +297,7 @@ def set_rthook():
253297
module_dir = dirname(PyInstaller.__file__)
254298
rthook = join(module_dir, "loader", "rthooks", "pyi_rth_qt5plugins.py")
255299
with open(rthook, "r") as hook: data = hook.read()
256-
if "sip.setapi" not in data:
300+
if "import sip" not in data:
257301
lines = data.split("\n")
258302
for line in lines:
259303
hook_file += line + "\n"
@@ -310,6 +354,7 @@ def run(self):
310354
'build': mybuild,
311355
'build_qt': build_qt,
312356
'build_exe': build_exe,
357+
'build_zip': build_zip,
313358
'build_dmg': build_dmg,
314359
'clean': myclean,
315360
'clean_local': clean_local

0 commit comments

Comments
 (0)