--- a/PluginPyInstaller.py Mon May 04 18:15:28 2020 +0200 +++ b/PluginPyInstaller.py Tue Jun 23 19:14:07 2020 +0200 @@ -7,12 +7,6 @@ Module implementing the PyInstaller interface plug-in. """ -from __future__ import unicode_literals -try: - str = unicode -except NameError: - pass - import os import platform import shutil @@ -33,7 +27,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "1.1.0" +version = "2.0.0" className = "PyInstallerPlugin" packageName = "PyInstaller" shortDescription = "Show dialogs to configure and execute PyInstaller." @@ -44,12 +38,10 @@ ) needsRestart = False pyqtApi = 2 -python2Compatible = True # End-Of-Header error = "" -exePy2 = [] exePy3 = [] @@ -76,7 +68,7 @@ } if _checkProgram(): - for exePath in (exePy2 + exePy3): + for exePath in exePy3: data["exe"] = exePath data["versionStartsWith"] = "" dataList.append(data.copy()) @@ -196,7 +188,6 @@ exes.append(exe) # step 2: determine the Python variant - _exePy2 = set() _exePy3 = set() versionArgs = ["-c", "import sys; print(sys.version_info[0])"] for exe in exes: @@ -212,12 +203,10 @@ versionStr = str(versionBytes, encoding='utf-8').strip() if versionStr == "3": _exePy3.add(exe) - elif versionStr == "2": - _exePy2.add(exe) finally: f.close() - executables = _exePy3 if majorVersion == 3 else _exePy2 + executables = _exePy3 # sort items, the probably newest topmost executables = list(executables) @@ -231,11 +220,10 @@ @return flag indicating availability (boolean) """ - global error, exePy2, exePy3 + global error, exePy3 - exePy2 = _findExecutable(2) exePy3 = _findExecutable(3) - if (exePy2 + exePy3) == []: + if not exePy3: if Utilities.isWindowsPlatform(): error = QCoreApplication.translate( "PyInstallerPlugin", @@ -387,8 +375,9 @@ @type QMenu """ if menuName == "Packagers": - enable = e5App().getObject("Project").getProjectLanguage() in [ - "Python", "Python2", "Python3"] + enable = ( + e5App().getObject("Project").getProjectLanguage() == "Python3" + ) for act in self.__projectActs: act.setEnabled(enable) @@ -423,35 +412,37 @@ if majorVersionStr == "Python3": executables = [f for f in exePy3 if f.endswith(("pyinstaller", "pyinstaller.exe"))] - else: - executables = [f for f in exePy2 if - f.endswith(("pyinstaller", "pyinstaller.exe"))] - if not executables: - E5MessageBox.critical( - self.__ui, - self.tr("pyinstaller"), - self.tr("""The pyinstaller executable could not be found.""")) - return - - # check if all files saved and errorfree before continue - if not project.checkAllScriptsDirty(reportSyntaxErrors=True): - return - - from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog - params = project.getData('PACKAGERSPARMS', "PYINSTALLER") - dlg = PyInstallerConfigDialog(project, executables, params, - mode="installer") - if dlg.exec_() == QDialog.Accepted: - args, params, script = dlg.generateParameters() - project.setData('PACKAGERSPARMS', "PYINSTALLER", params) + if not executables: + E5MessageBox.critical( + self.__ui, + self.tr("pyinstaller"), + self.tr("""The pyinstaller executable could not be""" + """ found.""")) + return + + # check if all files saved and errorfree before continue + if not project.checkAllScriptsDirty(reportSyntaxErrors=True): + return - # now do the call - from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog - dia = PyInstallerExecDialog("pyinstaller") - dia.show() - res = dia.start(args, params, project, script) - if res: - dia.exec_() + from PyInstaller.PyInstallerConfigDialog import ( + PyInstallerConfigDialog + ) + params = project.getData('PACKAGERSPARMS', "PYINSTALLER") + dlg = PyInstallerConfigDialog(project, executables, params, + mode="installer") + if dlg.exec_() == QDialog.Accepted: + args, params, script = dlg.generateParameters() + project.setData('PACKAGERSPARMS', "PYINSTALLER", params) + + # now do the call + from PyInstaller.PyInstallerExecDialog import ( + PyInstallerExecDialog + ) + dia = PyInstallerExecDialog("pyinstaller") + dia.show() + res = dia.start(args, params, project, script) + if res: + dia.exec_() @pyqtSlot() def __pyiMakeSpec(self): @@ -464,35 +455,37 @@ if majorVersionStr == "Python3": executables = [f for f in exePy3 if f.endswith(("pyi-makespec", "pyi-makespec.exe"))] - else: - executables = [f for f in exePy2 if - f.endswith(("pyi-makespec", "pyi-makespec.exe"))] - if not executables: - E5MessageBox.critical( - self.__ui, - self.tr("pyi-makespec"), - self.tr("""The pyi-makespec executable could not be found.""")) - return - - # check if all files saved and errorfree before continue - if not project.checkAllScriptsDirty(reportSyntaxErrors=True): - return - - from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog - params = project.getData('PACKAGERSPARMS', "PYINSTALLER") - dlg = PyInstallerConfigDialog(project, executables, params, - mode="spec") - if dlg.exec_() == QDialog.Accepted: - args, params, script = dlg.generateParameters() - project.setData('PACKAGERSPARMS', "PYINSTALLER", params) + if not executables: + E5MessageBox.critical( + self.__ui, + self.tr("pyi-makespec"), + self.tr("""The pyi-makespec executable could not be""" + """ found.""")) + return + + # check if all files saved and errorfree before continue + if not project.checkAllScriptsDirty(reportSyntaxErrors=True): + return - # now do the call - from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog - dia = PyInstallerExecDialog("pyinstaller") - dia.show() - res = dia.start(args, params, project, script) - if res: - dia.exec_() + from PyInstaller.PyInstallerConfigDialog import ( + PyInstallerConfigDialog + ) + params = project.getData('PACKAGERSPARMS', "PYINSTALLER") + dlg = PyInstallerConfigDialog(project, executables, params, + mode="spec") + if dlg.exec_() == QDialog.Accepted: + args, params, script = dlg.generateParameters() + project.setData('PACKAGERSPARMS', "PYINSTALLER", params) + + # now do the call + from PyInstaller.PyInstallerExecDialog import ( + PyInstallerExecDialog + ) + dia = PyInstallerExecDialog("pyinstaller") + dia.show() + res = dia.start(args, params, project, script) + if res: + dia.exec_() @pyqtSlot() def __pyinstallerCleanup(self):