--- a/PluginPyInstaller.py Fri Jan 19 17:08:15 2018 +0100 +++ b/PluginPyInstaller.py Sat Jan 20 15:58:14 2018 +0100 @@ -8,12 +8,17 @@ """ from __future__ import unicode_literals +try: + str = unicode +except NameError: + pass import os import platform import shutil -from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication, QTranslator +from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication, QTranslator, \ + QProcess from PyQt5.QtWidgets import QDialog from E5Gui import E5MessageBox @@ -178,24 +183,24 @@ exes.append(exe) # step 2: determine the Python variant - if Utilities.isMacPlatform(): - checkStrings = ["Python.framework/Versions/3".lower(), - "python3"] - else: - checkStrings = ["python3"] - _exePy2 = set() _exePy3 = set() + versionArgs = ["-c", "import sys; print(sys.version_info[0])"] for exe in exes: try: f = open(exe, "r") line0 = f.readline() - for checkStr in checkStrings: - if checkStr in line0.lower(): - _exePy3.add(exe) - break + program = line0.replace("#!", "").strip() + process = QProcess() + process.start(program, versionArgs) + process.waitForFinished(5000) + # get a QByteArray of the output + versionBytes = process.readAllStandardOutput() + versionStr = str(versionBytes, encoding='utf-8').strip() + if versionStr == "3": + _exePy3.add(exe) else: - _exePy2.add(exe) + _exePy2.add(exe) finally: f.close() @@ -456,7 +461,21 @@ if not project.checkAllScriptsDirty(reportSyntaxErrors=True): return - # TODO: implement pyi-makespec + 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):