build exe with python3/pyqt5

This commit is contained in:
Milan Nikolic 2014-12-21 16:27:11 +01:00
parent 3e23697c43
commit e6c9ed2d11
2 changed files with 14 additions and 9 deletions

View file

@ -29,14 +29,13 @@ Source: "m64py\*.txt"; DestDir: "{app}";
Source: "m64py\*.pyd"; DestDir: "{app}";
Source: "m64py\*.exe"; DestDir: "{app}";
Source: "m64py\*.dll"; DestDir: "{app}";
Source: "m64py\*.zip"; DestDir: "{app}";
Source: "m64py\AUTHORS"; DestDir: "{app}";
Source: "m64py\COPYING"; DestDir: "{app}";
Source: "m64py\README.md"; DestDir: "{app}";
Source: "m64py\ChangeLog"; DestDir: "{app}";
Source: "m64py\*.v64"; DestDir: "{app}\test";
Source: "m64py\qt5_plugins\codecs\*.dll"; DestDir: "{app}\qt5_plugins\codecs";
Source: "m64py\qt5_plugins\iconengines\*.dll"; DestDir: "{app}\qt5_plugins\iconengines";
Source: "m64py\qt5_plugins\imageformats\*.dll"; DestDir: "{app}\qt5_plugins\imageformats";
Source: "m64py\qt5_plugins\platforms\*.dll"; DestDir: "{app}\qt5_plugins\platforms";
Source: "m64py\doc\*"; DestDir: "{app}\doc";
[Icons]

View file

@ -80,7 +80,7 @@ class build_exe(Command):
def copy_emulator(self):
tempdir = tempfile.mkdtemp()
zippath = join(tempdir, basename(self.url))
urllib.urlretrieve(self.url, zippath)
urllib.request.urlretrieve(self.url, zippath)
zf = zipfile.ZipFile(zippath)
for name in zf.namelist():
if self.arch in name:
@ -101,17 +101,25 @@ class build_exe(Command):
shutil.rmtree(tempdir)
def copy_files(self):
tempdir = tempfile.mkdtemp()
dest_path = join(self.dist_dir, "m64py")
rar_dir = join(os.environ["ProgramFiles(x86)"], "Unrar")
if not os.path.isfile(join(rar_dir, "UnRAR.exe")):
urllib.urlretrieve("http://www.rarlab.com/rar/unrarw32.exe", join(tempdir, "unrar.exe"))
tempdir = tempfile.mkdtemp()
urllib.request.urlretrieve("http://www.rarlab.com/rar/unrarw32.exe", join(tempdir, "unrar.exe"))
subprocess.call([join(tempdir, "unrar.exe"), "-s"])
shutil.rmtree(tempdir)
shutil.copy(join(rar_dir, "UnRAR.exe"), dest_path)
shutil.copy(join(rar_dir, "license.txt"), join(dest_path, "doc", "unrar-license.txt"))
for file_name in ["AUTHORS", "ChangeLog", "COPYING", "LICENSES", "README.md"]:
shutil.copy(join(BASE_DIR, file_name), dest_path)
shutil.rmtree(tempdir)
import PyQt5
qt5_dir = dirname(PyQt5.__file__)
qwindows = join(qt5_dir, "plugins", "platforms", "qwindows.dll")
qwindows_dest = join(dest_path, "qt5_plugins", "platforms")
if not os.path.exists(qwindows_dest):
os.makedirs(qwindows_dest)
shutil.copy(qwindows, qwindows_dest)
def remove_files(self):
dest_path = join(self.dist_dir, "m64py")
@ -251,8 +259,6 @@ def set_rthook():
hook_file += line + "\n"
if "MEIPASS" in line:
hook_file += "\nimport sip\n"
hook_file += "sip.setapi('QString', 2)\n"
hook_file += "sip.setapi('QVariant', 2)\n"
with open(rthook, "w") as hook: hook.write(hook_file)