15 |
15 |
16 import os |
16 import os |
17 import platform |
17 import platform |
18 import shutil |
18 import shutil |
19 |
19 |
20 from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication, QTranslator, \ |
20 from PyQt5.QtCore import ( |
21 QProcess |
21 pyqtSlot, QObject, QCoreApplication, QTranslator, QProcess |
|
22 ) |
22 from PyQt5.QtWidgets import QDialog |
23 from PyQt5.QtWidgets import QDialog |
23 |
24 |
24 from E5Gui import E5MessageBox |
25 from E5Gui import E5MessageBox |
25 from E5Gui.E5Action import E5Action |
26 from E5Gui.E5Action import E5Action |
26 from E5Gui.E5Application import e5App |
27 from E5Gui.E5Application import e5App |
30 # Start-Of-Header |
31 # Start-Of-Header |
31 name = "PyInstaller Plugin" |
32 name = "PyInstaller Plugin" |
32 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
33 author = "Detlev Offenbach <detlev@die-offenbachs.de>" |
33 autoactivate = True |
34 autoactivate = True |
34 deactivateable = True |
35 deactivateable = True |
35 version = "1.0.2" |
36 version = "1.1.0" |
36 className = "PyInstallerPlugin" |
37 className = "PyInstallerPlugin" |
37 packageName = "PyInstaller" |
38 packageName = "PyInstaller" |
38 shortDescription = "Show dialogs to configure and execute PyInstaller." |
39 shortDescription = "Show dialogs to configure and execute PyInstaller." |
39 longDescription = ( |
40 longDescription = ( |
40 """This plug-in implements dialogs to configure and execute PyInstaller""" |
41 """This plug-in implements dialogs to configure and execute PyInstaller""" |
69 "versionCommand": "--version", |
70 "versionCommand": "--version", |
70 "versionStartsWith": "dummyExe", |
71 "versionStartsWith": "dummyExe", |
71 "versionPosition": -1, |
72 "versionPosition": -1, |
72 "version": "", |
73 "version": "", |
73 "versionCleanup": None, |
74 "versionCleanup": None, |
74 "versionRe": "^\d", |
75 "versionRe": "^\\d", |
75 } |
76 } |
76 |
77 |
77 if _checkProgram(): |
78 if _checkProgram(): |
78 for exePath in (exePy2 + exePy3): |
79 for exePath in (exePy2 + exePy3): |
79 data["exe"] = exePath |
80 data["exe"] = exePath |
159 exePaths = getExePath( |
160 exePaths = getExePath( |
160 winreg.HKEY_LOCAL_MACHINE, |
161 winreg.HKEY_LOCAL_MACHINE, |
161 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
162 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
162 for exePath in exePaths: |
163 for exePath in exePaths: |
163 executables.add(exePath) |
164 executables.add(exePath) |
|
165 |
|
166 if not executables and majorVersion >= 3: |
|
167 # check the PATH environment variable if nothing was found |
|
168 # Python 3 only |
|
169 path = Utilities.getEnvironmentEntry('PATH') |
|
170 if path: |
|
171 dirs = path.split(os.pathsep) |
|
172 for directory in dirs: |
|
173 for prog in ("pyinstaller.exe", "pyi-makespec.exe"): |
|
174 exe = os.path.join(directory, prog) |
|
175 if os.access(exe, os.X_OK): |
|
176 executables.add(exe) |
164 else: |
177 else: |
165 # |
178 # |
166 # Linux, Unix ... |
179 # Linux, Unix ... |
167 pyinstallerScripts = ['pyinstaller', 'pyi-makespec'] |
180 pyinstallerScripts = ['pyinstaller', 'pyi-makespec'] |
168 |
181 |
372 @type str |
385 @type str |
373 @param menu reference to the menu |
386 @param menu reference to the menu |
374 @type QMenu |
387 @type QMenu |
375 """ |
388 """ |
376 if menuName == "Packagers": |
389 if menuName == "Packagers": |
377 enable = e5App().getObject("Project").getProjectLanguage() in \ |
390 enable = e5App().getObject("Project").getProjectLanguage() in [ |
378 ["Python", "Python2", "Python3"] |
391 "Python", "Python2", "Python3"] |
379 for act in self.__projectActs: |
392 for act in self.__projectActs: |
380 act.setEnabled(enable) |
393 act.setEnabled(enable) |
381 |
394 |
382 def __loadTranslator(self): |
395 def __loadTranslator(self): |
383 """ |
396 """ |
384 Private method to load the translation file. |
397 Private method to load the translation file. |
385 """ |
398 """ |
386 if self.__ui is not None: |
399 if self.__ui is not None: |
387 loc = self.__ui.getLocale() |
400 loc = self.__ui.getLocale() |
388 if loc and loc != "C": |
401 if loc and loc != "C": |
389 locale_dir = \ |
402 locale_dir = os.path.join(os.path.dirname(__file__), |
390 os.path.join(os.path.dirname(__file__), |
403 "PyInstaller", "i18n") |
391 "PyInstaller", "i18n") |
|
392 translation = "pyinstaller_{0}".format(loc) |
404 translation = "pyinstaller_{0}".format(loc) |
393 translator = QTranslator(None) |
405 translator = QTranslator(None) |
394 loaded = translator.load(translation, locale_dir) |
406 loaded = translator.load(translation, locale_dir) |
395 if loaded: |
407 if loaded: |
396 self.__translator = translator |
408 self.__translator = translator |
487 """ |
499 """ |
488 Private slot to remove the directories created by pyinstaller. |
500 Private slot to remove the directories created by pyinstaller. |
489 """ |
501 """ |
490 project = e5App().getObject("Project") |
502 project = e5App().getObject("Project") |
491 |
503 |
492 from PyInstaller.PyInstallerCleanupDialog import \ |
504 from PyInstaller.PyInstallerCleanupDialog import ( |
493 PyInstallerCleanupDialog |
505 PyInstallerCleanupDialog |
|
506 ) |
494 dlg = PyInstallerCleanupDialog() |
507 dlg = PyInstallerCleanupDialog() |
495 if dlg.exec_() == QDialog.Accepted: |
508 if dlg.exec_() == QDialog.Accepted: |
496 removeDirs = dlg.getDirectories() |
509 removeDirs = dlg.getDirectories() |
497 for directory in removeDirs: |
510 for directory in removeDirs: |
498 rd = os.path.join(project.getProjectPath(), directory) |
511 rd = os.path.join(project.getProjectPath(), directory) |