Skip to content

Commit d4181b9

Browse files
committed
Update build_exe
1 parent d384a74 commit d4181b9

File tree

4 files changed

+11
-73
lines changed

4 files changed

+11
-73
lines changed

dist/windows/hooks/libdir.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

dist/windows/m64py.iss.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@ Source: "m64py\*.dll"; DestDir: "{app}";
3131
Source: "m64py\*.zip"; DestDir: "{app}";
3232
Source: "m64py\*.v64"; DestDir: "{app}";
3333
Source: "m64py\*.pyd"; DestDir: "{app}";
34-
Source: "m64py\lib\*"; DestDir: "{app}\lib";
3534
Source: "m64py\doc\*"; DestDir: "{app}\doc";
35+
Source: "m64py\PyQt5\*"; DestDir: "{app}\PyQt5"; Flags: recursesubdirs
3636
Source: "m64py\AUTHORS"; DestDir: "{app}";
3737
Source: "m64py\COPYING"; DestDir: "{app}";
3838
Source: "m64py\README.rst"; DestDir: "{app}";
3939
Source: "m64py\ChangeLog"; DestDir: "{app}";
40-
Source: "m64py\lib\qt5_plugins\platforms\qwindows.dll"; DestDir: "{app}\lib\qt5_plugins\platforms";
41-
Source: "m64py\lib\qt5_plugins\imageformats\qjpeg.dll"; DestDir: "{app}\lib\qt5_plugins\imageformats";
42-
Source: "m64py\lib\qt5_plugins\imageformats\qsvg.dll"; DestDir: "{app}\lib\qt5_plugins\imageformats";
4340

4441
[Icons]
4542
Name: {group}\M64Py; Filename: {app}\m64py.exe; Tasks: desktopicon;

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')], hiddenimports=['pickle', 'PyQt5.Qt'], pathex=[join(BASE_DIR, 'src')], hookspath=[join(DIST_DIR, 'hooks')], runtime_hooks=[join(DIST_DIR, 'hooks', 'libdir.py')])
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: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,6 @@ def run(self):
6969
self.compile_rc(os.path.join(dirpath, filename))
7070

7171

72-
def set_rthook():
73-
import PyInstaller
74-
hook_file = ""
75-
module_dir = os.path.dirname(PyInstaller.__file__)
76-
rthook = os.path.join(module_dir, "loader", "rthooks", "pyi_rth_qt5plugins.py")
77-
with open(rthook, "r") as hook:
78-
data = hook.read()
79-
if 'sys._MEIPASS, "lib"' not in data:
80-
lines = data.split("\n")
81-
for line in lines:
82-
if "MEIPASS" in line:
83-
hook_file += "d = os.path.join(sys._MEIPASS, \"lib\", d)\n"
84-
else:
85-
hook_file += line + "\n"
86-
with open(rthook, "w") as hook:
87-
hook.write(hook_file)
88-
89-
9072
class BuildDmg(setuptools.Command):
9173

9274
description = "Generate a .dmg file for distribution"
@@ -183,7 +165,6 @@ class BuildExe(setuptools.Command):
183165
user_options = []
184166

185167
arch = "i686-w64-mingw32.static"
186-
url = "https://bitbucket.org/ecsv/mupen64plus-mxe-daily/get/master.zip"
187168
dist_dir = os.path.join(BASE_DIR, "dist", "windows")
188169

189170
def initialize_options(self):
@@ -193,9 +174,7 @@ def finalize_options(self):
193174
pass
194175

195176
def copy_emulator(self):
196-
tempdir = tempfile.mkdtemp()
197-
zippath = os.path.join(tempdir, os.path.basename(self.url))
198-
urllib.request.urlretrieve(self.url, zippath)
177+
zippath = os.path.join(BASE_DIR, "dist", "windows", "bundle.zip")
199178
zip_file = zipfile.ZipFile(zippath)
200179
for name in zip_file.namelist():
201180
if self.arch in name:
@@ -214,7 +193,6 @@ def copy_emulator(self):
214193
unpacked.write(zip_file.read(name))
215194
unpacked.close()
216195
zip_file.close()
217-
shutil.rmtree(tempdir)
218196

219197
def copy_files(self):
220198
dest_path = os.path.join(self.dist_dir, "m64py")
@@ -231,38 +209,18 @@ def copy_files(self):
231209
for file_name in ["AUTHORS", "ChangeLog", "COPYING", "LICENSES", "README.rst"]:
232210
shutil.copy(os.path.join(BASE_DIR, file_name), dest_path)
233211

234-
import PyQt5
235-
qt5_dir = os.path.dirname(PyQt5.__file__)
236-
qwindows = os.path.join(qt5_dir, "Qt", "plugins", "platforms", "qwindows.dll")
237-
qwindows_dest = os.path.join(dest_path, "lib", "qt5_plugins", "platforms")
238-
if not os.path.exists(qwindows_dest):
239-
os.makedirs(qwindows_dest)
240-
shutil.copy(qwindows, qwindows_dest)
241-
242-
def move_files(self):
243-
dest_path = os.path.join(self.dist_dir, "m64py", "lib")
244-
plugins_path = os.path.join(self.dist_dir, "m64py", "qt5_plugins")
245-
shutil.copytree(plugins_path, os.path.join(dest_path, "qt5_plugins"))
246-
shutil.rmtree(plugins_path)
247-
248-
for file_name in glob.glob(os.path.join(self.dist_dir, "m64py", "*.pyd")):
249-
if "PyQt5" not in file_name:
250-
shutil.move(file_name, dest_path)
251-
252-
for file_name in glob.glob(os.path.join(self.dist_dir, "m64py", "api*.dll")):
253-
shutil.move(file_name, dest_path)
254-
255-
for file_name in glob.glob(os.path.join(self.dist_dir, "m64py", "*.dll")):
256-
print(file_name)
257-
if "python3" not in file_name and "mupen64plus" not in os.path.basename(file_name):
258-
shutil.move(file_name, dest_path)
259-
260212
def remove_files(self):
261213
dest_path = os.path.join(self.dist_dir, "m64py")
262214
for dir_name in ["api", "man6", "applications", "apps"]:
263215
shutil.rmtree(os.path.join(dest_path, dir_name), True)
264-
for file_name in glob.glob(os.path.join(dest_path, "glide*.exe")):
265-
os.remove(file_name)
216+
for dir_name in ["qml", "translations"]:
217+
shutil.rmtree(os.path.join(dest_path, "PyQt5", "Qt", dir_name), True)
218+
for file_name in glob.glob(os.path.join(dest_path, "PyQt5", "Qt*.pyd")):
219+
if os.path.basename(file_name) not in ["Qt.pyd", "QtCore.pyd", "QtGui.pyd", "QtWidgets.pyd", "QtOpenGL.pyd"]:
220+
os.remove(file_name)
221+
for file_name in glob.glob(os.path.join(dest_path, "Qt5*.dll")):
222+
if os.path.basename(file_name) not in ["Qt5Core.dll", "Qt5Gui.dll", "Qt5Widgets.dll", "Qt5OpenGL.dll"]:
223+
os.remove(file_name)
266224

267225
def run_build(self):
268226
import PyInstaller.building.build_main
@@ -295,10 +253,8 @@ def run_build_installer(self):
295253

296254
def run(self):
297255
self.run_command("build_qt")
298-
set_rthook()
299256
self.run_build()
300257
self.copy_emulator()
301-
self.move_files()
302258
self.copy_files()
303259
self.remove_files()
304260
self.run_build_installer()
@@ -346,11 +302,9 @@ def set_config_path():
346302

347303
def run(self):
348304
self.run_command("build_qt")
349-
set_rthook()
350305
self.set_config_path()
351306
self.run_build()
352307
self.copy_emulator()
353-
self.move_files()
354308
self.copy_files()
355309
self.remove_files()
356310
self.run_build_zip()

0 commit comments

Comments
 (0)