25 # Start-Of-Header |
25 # Start-Of-Header |
26 name = "PyInstaller Plugin" |
26 name = "PyInstaller Plugin" |
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
28 autoactivate = True |
28 autoactivate = True |
29 deactivateable = True |
29 deactivateable = True |
30 version = "2.0.1" |
30 version = "2.1.0" |
31 className = "PyInstallerPlugin" |
31 className = "PyInstallerPlugin" |
32 packageName = "PyInstaller" |
32 packageName = "PyInstaller" |
33 shortDescription = "Show dialogs to configure and execute PyInstaller." |
33 shortDescription = "Show dialogs to configure and execute PyInstaller." |
34 longDescription = ( |
34 longDescription = ( |
35 """This plug-in implements dialogs to configure and execute PyInstaller""" |
35 """This plug-in implements dialogs to configure and execute PyInstaller""" |
189 |
189 |
190 # step 2: determine the Python variant |
190 # step 2: determine the Python variant |
191 _exePy3 = set() |
191 _exePy3 = set() |
192 versionArgs = ["-c", "import sys; print(sys.version_info[0])"] |
192 versionArgs = ["-c", "import sys; print(sys.version_info[0])"] |
193 for exe in exes: |
193 for exe in exes: |
194 try: |
194 with open(exe, "r") as f: |
195 f = open(exe, "r") |
|
196 line0 = f.readline() |
195 line0 = f.readline() |
197 program = line0.replace("#!", "").strip() |
196 program = line0.replace("#!", "").strip() |
198 process = QProcess() |
197 process = QProcess() |
199 process.start(program, versionArgs) |
198 process.start(program, versionArgs) |
200 process.waitForFinished(5000) |
199 process.waitForFinished(5000) |
201 # get a QByteArray of the output |
200 # get a QByteArray of the output |
202 versionBytes = process.readAllStandardOutput() |
201 versionBytes = process.readAllStandardOutput() |
203 versionStr = str(versionBytes, encoding='utf-8').strip() |
202 versionStr = str(versionBytes, encoding='utf-8').strip() |
204 if versionStr == "3": |
203 if versionStr == "3": |
205 _exePy3.add(exe) |
204 _exePy3.add(exe) |
206 finally: |
|
207 f.close() |
|
208 |
205 |
209 executables = _exePy3 |
206 executables = _exePy3 |
210 |
207 |
211 # sort items, the probably newest topmost |
208 # sort items, the probably newest topmost |
212 executables = list(executables) |
209 executables = list(executables) |
428 PyInstallerConfigDialog |
425 PyInstallerConfigDialog |
429 ) |
426 ) |
430 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
427 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
431 dlg = PyInstallerConfigDialog(project, executables, params, |
428 dlg = PyInstallerConfigDialog(project, executables, params, |
432 mode="installer") |
429 mode="installer") |
433 if dlg.exec_() == QDialog.Accepted: |
430 if dlg.exec() == QDialog.Accepted: |
434 args, params, script = dlg.generateParameters() |
431 args, params, script = dlg.generateParameters() |
435 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
432 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
436 |
433 |
437 # now do the call |
434 # now do the call |
438 from PyInstaller.PyInstallerExecDialog import ( |
435 from PyInstaller.PyInstallerExecDialog import ( |
440 ) |
437 ) |
441 dia = PyInstallerExecDialog("pyinstaller") |
438 dia = PyInstallerExecDialog("pyinstaller") |
442 dia.show() |
439 dia.show() |
443 res = dia.start(args, params, project, script) |
440 res = dia.start(args, params, project, script) |
444 if res: |
441 if res: |
445 dia.exec_() |
442 dia.exec() |
446 |
443 |
447 @pyqtSlot() |
444 @pyqtSlot() |
448 def __pyiMakeSpec(self): |
445 def __pyiMakeSpec(self): |
449 """ |
446 """ |
450 Private slot to execute the pyi-makespec command for the current |
447 Private slot to execute the pyi-makespec command for the current |
471 PyInstallerConfigDialog |
468 PyInstallerConfigDialog |
472 ) |
469 ) |
473 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
470 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
474 dlg = PyInstallerConfigDialog(project, executables, params, |
471 dlg = PyInstallerConfigDialog(project, executables, params, |
475 mode="spec") |
472 mode="spec") |
476 if dlg.exec_() == QDialog.Accepted: |
473 if dlg.exec() == QDialog.Accepted: |
477 args, params, script = dlg.generateParameters() |
474 args, params, script = dlg.generateParameters() |
478 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
475 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
479 |
476 |
480 # now do the call |
477 # now do the call |
481 from PyInstaller.PyInstallerExecDialog import ( |
478 from PyInstaller.PyInstallerExecDialog import ( |
483 ) |
480 ) |
484 dia = PyInstallerExecDialog("pyinstaller") |
481 dia = PyInstallerExecDialog("pyinstaller") |
485 dia.show() |
482 dia.show() |
486 res = dia.start(args, params, project, script) |
483 res = dia.start(args, params, project, script) |
487 if res: |
484 if res: |
488 dia.exec_() |
485 dia.exec() |
489 |
486 |
490 @pyqtSlot() |
487 @pyqtSlot() |
491 def __pyinstallerCleanup(self): |
488 def __pyinstallerCleanup(self): |
492 """ |
489 """ |
493 Private slot to remove the directories created by pyinstaller. |
490 Private slot to remove the directories created by pyinstaller. |
496 |
493 |
497 from PyInstaller.PyInstallerCleanupDialog import ( |
494 from PyInstaller.PyInstallerCleanupDialog import ( |
498 PyInstallerCleanupDialog |
495 PyInstallerCleanupDialog |
499 ) |
496 ) |
500 dlg = PyInstallerCleanupDialog() |
497 dlg = PyInstallerCleanupDialog() |
501 if dlg.exec_() == QDialog.Accepted: |
498 if dlg.exec() == QDialog.Accepted: |
502 removeDirs = dlg.getDirectories() |
499 removeDirs = dlg.getDirectories() |
503 for directory in removeDirs: |
500 for directory in removeDirs: |
504 rd = os.path.join(project.getProjectPath(), directory) |
501 rd = os.path.join(project.getProjectPath(), directory) |
505 shutil.rmtree(rd, ignore_errors=True) |
502 shutil.rmtree(rd, ignore_errors=True) |
506 |
503 |