31 # Start-Of-Header |
25 # Start-Of-Header |
32 name = "PyInstaller Plugin" |
26 name = "PyInstaller Plugin" |
33 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
34 autoactivate = True |
28 autoactivate = True |
35 deactivateable = True |
29 deactivateable = True |
36 version = "1.1.0" |
30 version = "2.0.0" |
37 className = "PyInstallerPlugin" |
31 className = "PyInstallerPlugin" |
38 packageName = "PyInstaller" |
32 packageName = "PyInstaller" |
39 shortDescription = "Show dialogs to configure and execute PyInstaller." |
33 shortDescription = "Show dialogs to configure and execute PyInstaller." |
40 longDescription = ( |
34 longDescription = ( |
41 """This plug-in implements dialogs to configure and execute PyInstaller""" |
35 """This plug-in implements dialogs to configure and execute PyInstaller""" |
42 """ for an eric project. PyInstaller must be available or must be""" |
36 """ for an eric project. PyInstaller must be available or must be""" |
43 """ installed via 'pip install PyInstaller'.""" |
37 """ installed via 'pip install PyInstaller'.""" |
44 ) |
38 ) |
45 needsRestart = False |
39 needsRestart = False |
46 pyqtApi = 2 |
40 pyqtApi = 2 |
47 python2Compatible = True |
|
48 # End-Of-Header |
41 # End-Of-Header |
49 |
42 |
50 error = "" |
43 error = "" |
51 |
44 |
52 exePy2 = [] |
|
53 exePy3 = [] |
45 exePy3 = [] |
54 |
46 |
55 |
47 |
56 def exeDisplayDataList(): |
48 def exeDisplayDataList(): |
57 """ |
49 """ |
210 # get a QByteArray of the output |
201 # get a QByteArray of the output |
211 versionBytes = process.readAllStandardOutput() |
202 versionBytes = process.readAllStandardOutput() |
212 versionStr = str(versionBytes, encoding='utf-8').strip() |
203 versionStr = str(versionBytes, encoding='utf-8').strip() |
213 if versionStr == "3": |
204 if versionStr == "3": |
214 _exePy3.add(exe) |
205 _exePy3.add(exe) |
215 elif versionStr == "2": |
|
216 _exePy2.add(exe) |
|
217 finally: |
206 finally: |
218 f.close() |
207 f.close() |
219 |
208 |
220 executables = _exePy3 if majorVersion == 3 else _exePy2 |
209 executables = _exePy3 |
221 |
210 |
222 # sort items, the probably newest topmost |
211 # sort items, the probably newest topmost |
223 executables = list(executables) |
212 executables = list(executables) |
224 executables.sort(reverse=True) |
213 executables.sort(reverse=True) |
225 return executables |
214 return executables |
229 """ |
218 """ |
230 Restricted function to check the availability of pyinstaller. |
219 Restricted function to check the availability of pyinstaller. |
231 |
220 |
232 @return flag indicating availability (boolean) |
221 @return flag indicating availability (boolean) |
233 """ |
222 """ |
234 global error, exePy2, exePy3 |
223 global error, exePy3 |
235 |
224 |
236 exePy2 = _findExecutable(2) |
|
237 exePy3 = _findExecutable(3) |
225 exePy3 = _findExecutable(3) |
238 if (exePy2 + exePy3) == []: |
226 if not exePy3: |
239 if Utilities.isWindowsPlatform(): |
227 if Utilities.isWindowsPlatform(): |
240 error = QCoreApplication.translate( |
228 error = QCoreApplication.translate( |
241 "PyInstallerPlugin", |
229 "PyInstallerPlugin", |
242 "The pyinstaller.exe executable could not be found." |
230 "The pyinstaller.exe executable could not be found." |
243 ) |
231 ) |
385 @type str |
373 @type str |
386 @param menu reference to the menu |
374 @param menu reference to the menu |
387 @type QMenu |
375 @type QMenu |
388 """ |
376 """ |
389 if menuName == "Packagers": |
377 if menuName == "Packagers": |
390 enable = e5App().getObject("Project").getProjectLanguage() in [ |
378 enable = ( |
391 "Python", "Python2", "Python3"] |
379 e5App().getObject("Project").getProjectLanguage() == "Python3" |
|
380 ) |
392 for act in self.__projectActs: |
381 for act in self.__projectActs: |
393 act.setEnabled(enable) |
382 act.setEnabled(enable) |
394 |
383 |
395 def __loadTranslator(self): |
384 def __loadTranslator(self): |
396 """ |
385 """ |
421 project = e5App().getObject("Project") |
410 project = e5App().getObject("Project") |
422 majorVersionStr = project.getProjectLanguage() |
411 majorVersionStr = project.getProjectLanguage() |
423 if majorVersionStr == "Python3": |
412 if majorVersionStr == "Python3": |
424 executables = [f for f in exePy3 if |
413 executables = [f for f in exePy3 if |
425 f.endswith(("pyinstaller", "pyinstaller.exe"))] |
414 f.endswith(("pyinstaller", "pyinstaller.exe"))] |
426 else: |
415 if not executables: |
427 executables = [f for f in exePy2 if |
416 E5MessageBox.critical( |
428 f.endswith(("pyinstaller", "pyinstaller.exe"))] |
417 self.__ui, |
429 if not executables: |
418 self.tr("pyinstaller"), |
430 E5MessageBox.critical( |
419 self.tr("""The pyinstaller executable could not be""" |
431 self.__ui, |
420 """ found.""")) |
432 self.tr("pyinstaller"), |
421 return |
433 self.tr("""The pyinstaller executable could not be found.""")) |
422 |
434 return |
423 # check if all files saved and errorfree before continue |
435 |
424 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
436 # check if all files saved and errorfree before continue |
425 return |
437 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
426 |
438 return |
427 from PyInstaller.PyInstallerConfigDialog import ( |
439 |
428 PyInstallerConfigDialog |
440 from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog |
429 ) |
441 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
430 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
442 dlg = PyInstallerConfigDialog(project, executables, params, |
431 dlg = PyInstallerConfigDialog(project, executables, params, |
443 mode="installer") |
432 mode="installer") |
444 if dlg.exec_() == QDialog.Accepted: |
433 if dlg.exec_() == QDialog.Accepted: |
445 args, params, script = dlg.generateParameters() |
434 args, params, script = dlg.generateParameters() |
446 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
435 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
447 |
436 |
448 # now do the call |
437 # now do the call |
449 from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog |
438 from PyInstaller.PyInstallerExecDialog import ( |
450 dia = PyInstallerExecDialog("pyinstaller") |
439 PyInstallerExecDialog |
451 dia.show() |
440 ) |
452 res = dia.start(args, params, project, script) |
441 dia = PyInstallerExecDialog("pyinstaller") |
453 if res: |
442 dia.show() |
454 dia.exec_() |
443 res = dia.start(args, params, project, script) |
|
444 if res: |
|
445 dia.exec_() |
455 |
446 |
456 @pyqtSlot() |
447 @pyqtSlot() |
457 def __pyiMakeSpec(self): |
448 def __pyiMakeSpec(self): |
458 """ |
449 """ |
459 Private slot to execute the pyi-makespec command for the current |
450 Private slot to execute the pyi-makespec command for the current |
462 project = e5App().getObject("Project") |
453 project = e5App().getObject("Project") |
463 majorVersionStr = project.getProjectLanguage() |
454 majorVersionStr = project.getProjectLanguage() |
464 if majorVersionStr == "Python3": |
455 if majorVersionStr == "Python3": |
465 executables = [f for f in exePy3 if |
456 executables = [f for f in exePy3 if |
466 f.endswith(("pyi-makespec", "pyi-makespec.exe"))] |
457 f.endswith(("pyi-makespec", "pyi-makespec.exe"))] |
467 else: |
458 if not executables: |
468 executables = [f for f in exePy2 if |
459 E5MessageBox.critical( |
469 f.endswith(("pyi-makespec", "pyi-makespec.exe"))] |
460 self.__ui, |
470 if not executables: |
461 self.tr("pyi-makespec"), |
471 E5MessageBox.critical( |
462 self.tr("""The pyi-makespec executable could not be""" |
472 self.__ui, |
463 """ found.""")) |
473 self.tr("pyi-makespec"), |
464 return |
474 self.tr("""The pyi-makespec executable could not be found.""")) |
465 |
475 return |
466 # check if all files saved and errorfree before continue |
476 |
467 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
477 # check if all files saved and errorfree before continue |
468 return |
478 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
469 |
479 return |
470 from PyInstaller.PyInstallerConfigDialog import ( |
480 |
471 PyInstallerConfigDialog |
481 from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog |
472 ) |
482 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
473 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
483 dlg = PyInstallerConfigDialog(project, executables, params, |
474 dlg = PyInstallerConfigDialog(project, executables, params, |
484 mode="spec") |
475 mode="spec") |
485 if dlg.exec_() == QDialog.Accepted: |
476 if dlg.exec_() == QDialog.Accepted: |
486 args, params, script = dlg.generateParameters() |
477 args, params, script = dlg.generateParameters() |
487 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
478 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
488 |
479 |
489 # now do the call |
480 # now do the call |
490 from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog |
481 from PyInstaller.PyInstallerExecDialog import ( |
491 dia = PyInstallerExecDialog("pyinstaller") |
482 PyInstallerExecDialog |
492 dia.show() |
483 ) |
493 res = dia.start(args, params, project, script) |
484 dia = PyInstallerExecDialog("pyinstaller") |
494 if res: |
485 dia.show() |
495 dia.exec_() |
486 res = dia.start(args, params, project, script) |
|
487 if res: |
|
488 dia.exec_() |
496 |
489 |
497 @pyqtSlot() |
490 @pyqtSlot() |
498 def __pyinstallerCleanup(self): |
491 def __pyinstallerCleanup(self): |
499 """ |
492 """ |
500 Private slot to remove the directories created by pyinstaller. |
493 Private slot to remove the directories created by pyinstaller. |