PluginPyInstaller.py

Fri, 19 Jan 2018 17:08:15 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 19 Jan 2018 17:08:15 +0100
changeset 5
8c92d66d20e4
parent 4
52f0572b5908
child 6
0f0f1598fc4a
permissions
-rw-r--r--

Continued implementing the PyInstaller interface (implemented the execution dialog).

1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
1 # -*- coding: utf-8 -*-
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
4 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
5
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
6 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
7 Module implementing the PyInstaller interface plug-in.
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
8 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
9
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
10 from __future__ import unicode_literals
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
11
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
12 import os
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
13 import platform
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
14 import shutil
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
15
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
16 from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication, QTranslator
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
17 from PyQt5.QtWidgets import QDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
18
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
19 from E5Gui import E5MessageBox
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
20 from E5Gui.E5Action import E5Action
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
21 from E5Gui.E5Application import e5App
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
22
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
23 import Utilities
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
24
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
25 # Start-Of-Header
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
26 name = "PyInstaller Plugin"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
27 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
28 autoactivate = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
29 deactivateable = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
30 version = "0.1.0"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
31 className = "PyInstallerPlugin"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
32 packageName = "PyInstaller"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
33 shortDescription = "Show dialogs to configure and execute PyInstaller."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
34 longDescription = (
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
35 """This plug-in implements dialogs to configure and execute PyInstaller"""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
36 """ for an eric project. PyInstaller must be available or must be"""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
37 """ installed via 'pip install PyInstaller'."""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
38 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
39 needsRestart = False
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
40 pyqtApi = 2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
41 python2Compatible = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
42 # End-Of-Header
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
43
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
44 error = ""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
45
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
46 exePy2 = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
47 exePy3 = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
48
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
49
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
50 def exeDisplayDataList():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
51 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
52 Module function to support the display of some executable info.
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
53
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
54 @return list of dictionaries containing the data to query the presence of
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
55 the executable
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
56 @rtype list of dict
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
57 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
58 dataList = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
59 data = {
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
60 "programEntry": True,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
61 "header": QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
62 "PyInstallerPlugin", "Packagers - PyInstaller"),
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
63 "exe": "dummyExe",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
64 "versionCommand": "--version",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
65 "versionStartsWith": "dummyExe",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
66 "versionPosition": -1,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
67 "version": "",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
68 "versionCleanup": None,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
69 "versionRe": "^\d",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
70 }
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
71
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
72 if _checkProgram():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
73 for exePath in (exePy2 + exePy3):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
74 data["exe"] = exePath
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
75 data["versionStartsWith"] = ""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
76 dataList.append(data.copy())
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
77 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
78 dataList.append(data)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
79 return dataList
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
80
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
81
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
82 def _findExecutable(majorVersion):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
83 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
84 Restricted function to determine the names of the executables.
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
85
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
86 @param majorVersion major python version
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
87 @type int
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
88 @return names of the executables
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
89 @rtype list of str
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
90 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
91 # Determine Python Version
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
92 if majorVersion == 3:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
93 minorVersions = range(10)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
94 elif majorVersion == 2:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
95 minorVersions = [7] # PyInstaller supports just Python 2.7
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
96 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
97 return []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
98
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
99 executables = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
100 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
101 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
102 # Windows
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
103 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
104 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
105 import winreg
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
106 except ImportError:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
107 import _winreg as winreg # __IGNORE_WARNING__
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
108
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
109 def getExePath(branch, access, versionStr):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
110 exes = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
111 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
112 software = winreg.OpenKey(branch, 'Software', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
113 python = winreg.OpenKey(software, 'Python', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
114 pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
115 version = winreg.OpenKey(pcore, versionStr, 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
116 installpath = winreg.QueryValue(version, 'InstallPath')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
117 # Look for pyinstaller.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
118 exe = os.path.join(installpath, 'Scripts', 'pyinstaller.exe')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
119 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
120 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
121 # Look for pyi-makespec.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
122 exe = os.path.join(installpath, 'Scripts', 'pyi-makespec.exe')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
123 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
124 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
125 except (WindowsError, OSError): # __IGNORE_WARNING__
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
126 pass
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
127 return exes
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
128
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
129 versionSuffixes = ["", "-32", "-64"]
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
130 for minorVersion in minorVersions:
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
131 for versionSuffix in versionSuffixes:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
132 versionStr = '{0}.{1}{2}'.format(majorVersion, minorVersion,
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
133 versionSuffix)
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
134 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
135 winreg.HKEY_CURRENT_USER,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
136 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
137 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
138 executables.add(exePath)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
139
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
140 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
141 winreg.HKEY_LOCAL_MACHINE,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
142 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
143 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
144 executables.add(exePath)
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
145
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
146 # Even on Intel 64-bit machines it's 'AMD64'
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
147 if platform.machine() == 'AMD64':
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
148 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
149 winreg.HKEY_CURRENT_USER,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
150 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
151 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
152 executables.add(exePath)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
153
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
154 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
155 winreg.HKEY_LOCAL_MACHINE,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
156 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
157 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
158 executables.add(exePath)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
159 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
160 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
161 # Linux, Unix ...
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
162 pyinstallerScripts = ['pyinstaller', 'pyi-makespec']
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
163
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
164 # There could be multiple pyinstaller executables in the path
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
165 # e.g. for different python variants
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
166 path = Utilities.getEnvironmentEntry('PATH')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
167 # environment variable not defined
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
168 if path is None:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
169 return []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
170
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
171 # step 1: determine possible candidates
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
172 exes = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
173 dirs = path.split(os.pathsep)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
174 for directory in dirs:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
175 for pyinstallerScript in pyinstallerScripts:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
176 exe = os.path.join(directory, pyinstallerScript)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
177 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
178 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
179
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
180 # step 2: determine the Python variant
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
181 if Utilities.isMacPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
182 checkStrings = ["Python.framework/Versions/3".lower(),
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
183 "python3"]
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
184 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
185 checkStrings = ["python3"]
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
186
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
187 _exePy2 = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
188 _exePy3 = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
189 for exe in exes:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
190 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
191 f = open(exe, "r")
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
192 line0 = f.readline()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
193 for checkStr in checkStrings:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
194 if checkStr in line0.lower():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
195 _exePy3.add(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
196 break
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
197 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
198 _exePy2.add(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
199 finally:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
200 f.close()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
201
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
202 executables = _exePy3 if majorVersion == 3 else _exePy2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
203
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
204 # sort items, the probably newest topmost
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
205 executables = list(executables)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
206 executables.sort(reverse=True)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
207 return executables
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
208
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
209
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
210 def _checkProgram():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
211 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
212 Restricted function to check the availability of pyinstaller.
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
213
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
214 @return flag indicating availability (boolean)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
215 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
216 global error, exePy2, exePy3
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
217
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
218 exePy2 = _findExecutable(2)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
219 exePy3 = _findExecutable(3)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
220 if (exePy2 + exePy3) == []:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
221 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
222 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
223 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
224 "The pyinstaller.exe executable could not be found."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
225 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
226 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
227 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
228 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
229 "The pyinstaller executable could not be found."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
230 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
231 return False
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
232 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
233 return True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
234
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
235
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
236 class PyInstallerPlugin(QObject):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
237 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
238 Class implementing the PyInstaller interface plug-in.
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
239 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
240 def __init__(self, ui):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
241 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
242 Constructor
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
243
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
244 @param ui reference to the user interface object
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
245 @type UI.UserInterface
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
246 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
247 super(PyInstallerPlugin, self).__init__(ui)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
248 self.__ui = ui
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
249
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
250 self.__initialize()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
251 _checkProgram()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
252
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
253 self.__translator = None
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
254 self.__loadTranslator()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
255
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
256 def __initialize(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
257 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
258 Private slot to (re)initialize the plug-in.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
259 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
260 self.__projectActs = []
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
261
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
262 def activate(self):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
263 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
264 Public method to activate this plug-in.
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
265
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
266 @return tuple of None and activation status (boolean)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
267 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
268 global error
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
269
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
270 # There is already an error, don't activate
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
271 if error:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
272 return None, False
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
273
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
274 # pyinstaller interface is only activated if it is available
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
275 if not _checkProgram():
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
276 return None, False
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
277
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
278 # clear previous error
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
279 error = ""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
280
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
281 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
282 menu = project.getMenu("Packagers")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
283 if menu:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
284 # Execute PyInstaller
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
285 act = E5Action(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
286 self.tr('Execute PyInstaller'),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
287 self.tr('Execute Py&Installer'), 0, 0,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
288 self, 'packagers_pyinstaller_run')
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
289 act.setStatusTip(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
290 self.tr('Generate a distribution package using PyInstaller'))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
291 act.setWhatsThis(self.tr(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
292 """<b>Execute PyInstaller</b>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
293 """<p>Generate a distribution package using PyInstaller."""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
294 """ The command is executed in the project path. All"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
295 """ files and directories must be given absolute or"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
296 """ relative to the project directory.</p>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
297 ))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
298 act.triggered.connect(self.__pyinstaller)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
299 menu.addAction(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
300 self.__projectActs.append(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
301
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
302 # Execute pyi-makespec
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
303 act = E5Action(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
304 self.tr('Make PyInstaller Spec File'),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
305 self.tr('Make PyInstaller &Spec File'), 0, 0,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
306 self, 'packagers_pyinstaller_spec')
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
307 act.setStatusTip(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
308 self.tr('Generate a spec file to be used by PyInstaller'))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
309 act.setWhatsThis(self.tr(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
310 """<b>Make PyInstaller Spec File</b>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
311 """<p>Generate a spec file to be used by PyInstaller"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
312 """ PyInstaller. The command is executed in the project"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
313 """ path. All files and directories must be given absolute"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
314 """ or relative to the project directory.</p>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
315 ))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
316 act.triggered.connect(self.__pyiMakeSpec)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
317 menu.addAction(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
318 self.__projectActs.append(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
319
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
320 # clean the pyinstaller created directories
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
321 act = E5Action(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
322 self.tr('Clean PyInstaller'),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
323 self.tr('&Clean PyInstaller'), 0, 0,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
324 self, 'packagers_pyinstaller_clean')
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
325 act.setStatusTip(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
326 self.tr('Remove the PyInstaller created directories'))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
327 act.setWhatsThis(self.tr(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
328 """<b>Clean PyInstaller</b>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
329 """<p>Remove the PyInstaller created directories (dist and"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
330 """ build). These are subdirectories within the project"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
331 """ path."""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
332 ))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
333 act.triggered.connect(self.__pyinstallerCleanup)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
334 menu.addAction(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
335 self.__projectActs.append(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
336
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
337 project.addE5Actions(self.__projectActs)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
338 project.showMenu.connect(self.__projectShowMenu)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
339
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
340 return None, True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
341
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
342 def deactivate(self):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
343 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
344 Public method to deactivate this plug-in.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
345 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
346 menu = e5App().getObject("Project").getMenu("Packagers")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
347 if menu:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
348 for act in self.__projectActs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
349 menu.removeAction(act)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
350
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
351 e5App().getObject("Project").removeE5Actions(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
352 self.__projectActs)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
353
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
354 self.__initialize()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
355
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
356 def __projectShowMenu(self, menuName, menu):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
357 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
358 Private slot called, when the the project menu or a submenu is
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
359 about to be shown.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
360
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
361 @param menuName name of the menu to be shown
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
362 @type str
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
363 @param menu reference to the menu
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
364 @type QMenu
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
365 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
366 if menuName == "Packagers":
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
367 enable = e5App().getObject("Project").getProjectLanguage() in \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
368 ["Python", "Python2", "Python3"]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
369 for act in self.__projectActs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
370 act.setEnabled(enable)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
371
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
372 def __loadTranslator(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
373 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
374 Private method to load the translation file.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
375 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
376 if self.__ui is not None:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
377 loc = self.__ui.getLocale()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
378 if loc and loc != "C":
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
379 locale_dir = \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
380 os.path.join(os.path.dirname(__file__),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
381 "PyInstaller", "i18n")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
382 translation = "pyinstaller_{0}".format(loc)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
383 translator = QTranslator(None)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
384 loaded = translator.load(translation, locale_dir)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
385 if loaded:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
386 self.__translator = translator
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
387 e5App().installTranslator(self.__translator)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
388 else:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
389 print("Warning: translation file '{0}' could not be"
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
390 " loaded.".format(translation))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
391 print("Using default.")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
392
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
393 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
394 def __pyinstaller(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
395 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
396 Private slot to execute the pyinstaller command for the current
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
397 project.
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
398 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
399 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
400 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
401 if majorVersionStr == "Python3":
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
402 executables = [f for f in exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
403 f.endswith(("pyinstaller", "pyinstaller.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
404 else:
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
405 executables = [f for f in exePy2 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
406 f.endswith(("pyinstaller", "pyinstaller.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
407 if not executables:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
408 E5MessageBox.critical(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
409 self.__ui,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
410 self.tr("pyinstaller"),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
411 self.tr("""The pyinstaller executable could not be found."""))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
412 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
413
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
414 # check if all files saved and errorfree before continue
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
415 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
416 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
417
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
418 from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
419 params = project.getData('PACKAGERSPARMS', "PYINSTALLER")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
420 dlg = PyInstallerConfigDialog(project, executables, params,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
421 mode="installer")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
422 if dlg.exec_() == QDialog.Accepted:
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
423 args, params, script = dlg.generateParameters()
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
424 project.setData('PACKAGERSPARMS', "PYINSTALLER", params)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
425
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
426 # now do the call
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
427 from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
428 dia = PyInstallerExecDialog("pyinstaller")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
429 dia.show()
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
430 res = dia.start(args, params, project, script)
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
431 if res:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
432 dia.exec_()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
433
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
434 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
435 def __pyiMakeSpec(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
436 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
437 Private slot to execute the pyi-makespec command for the current
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
438 project to generate a spec file to be used by pyinstaller.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
439 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
440 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
441 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
442 if majorVersionStr == "Python3":
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
443 executables = [f for f in exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
444 f.endswith(("pyi-makespec", "pyi-makespec.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
445 else:
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
446 executables = [f for f in exePy2 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
447 f.endswith(("pyi-makespec", "pyi-makespec.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
448 if not executables:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
449 E5MessageBox.critical(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
450 self.__ui,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
451 self.tr("pyi-makespec"),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
452 self.tr("""The pyi-makespec executable could not be found."""))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
453 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
454
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
455 # check if all files saved and errorfree before continue
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
456 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
457 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
458
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
459 # TODO: implement pyi-makespec
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
460
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
461 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
462 def __pyinstallerCleanup(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
463 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
464 Private slot to remove the directories created by pyinstaller.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
465 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
466 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
467
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
468 from PyInstaller.PyInstallerCleanupDialog import \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
469 PyInstallerCleanupDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
470 dlg = PyInstallerCleanupDialog()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
471 if dlg.exec_() == QDialog.Accepted:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
472 removeDirs = dlg.getDirectories()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
473 for directory in removeDirs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
474 rd = os.path.join(project.getProjectPath(), directory)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
475 shutil.rmtree(rd, ignore_errors=True)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
476
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
477 #
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
478 # eflag: noqa = M801

eric ide

mercurial