79 |
78 |
80 |
79 |
81 def _findExecutable(majorVersion): |
80 def _findExecutable(majorVersion): |
82 """ |
81 """ |
83 Restricted function to determine the names of the executables. |
82 Restricted function to determine the names of the executables. |
84 |
83 |
85 @param majorVersion major python version |
84 @param majorVersion major python version |
86 @type int |
85 @type int |
87 @return names of the executables |
86 @return names of the executables |
88 @rtype list of str |
87 @rtype list of str |
89 """ |
88 """ |
90 # Determine Python Version |
89 # Determine Python Version |
91 if majorVersion == 3: |
90 if majorVersion == 3: |
92 minorVersions = range(16) |
91 minorVersions = range(16) |
93 else: |
92 else: |
94 return [] |
93 return [] |
95 |
94 |
96 executables = set() |
95 executables = set() |
97 if Utilities.isWindowsPlatform(): |
96 if Utilities.isWindowsPlatform(): |
98 # |
97 # |
99 # Windows |
98 # Windows |
100 # |
99 # |
101 try: |
100 try: |
102 import winreg |
101 import winreg |
103 except ImportError: |
102 except ImportError: |
104 import _winreg as winreg # __IGNORE_WARNING__ |
103 import _winreg as winreg # __IGNORE_WARNING__ |
105 |
104 |
106 def getExePath(branch, access, versionStr): |
105 def getExePath(branch, access, versionStr): |
107 exes = [] |
106 exes = [] |
108 with contextlib.suppress(WindowsError, OSError): |
107 with contextlib.suppress(WindowsError, OSError): |
109 software = winreg.OpenKey(branch, 'Software', 0, access) |
108 software = winreg.OpenKey(branch, "Software", 0, access) |
110 python = winreg.OpenKey(software, 'Python', 0, access) |
109 python = winreg.OpenKey(software, "Python", 0, access) |
111 pcore = winreg.OpenKey(python, 'PythonCore', 0, access) |
110 pcore = winreg.OpenKey(python, "PythonCore", 0, access) |
112 version = winreg.OpenKey(pcore, versionStr, 0, access) |
111 version = winreg.OpenKey(pcore, versionStr, 0, access) |
113 installpath = winreg.QueryValue(version, 'InstallPath') |
112 installpath = winreg.QueryValue(version, "InstallPath") |
114 # Look for pyinstaller.exe |
113 # Look for pyinstaller.exe |
115 exe = os.path.join(installpath, 'Scripts', 'pyinstaller.exe') |
114 exe = os.path.join(installpath, "Scripts", "pyinstaller.exe") |
116 if os.access(exe, os.X_OK): |
115 if os.access(exe, os.X_OK): |
117 exes.append(exe) |
116 exes.append(exe) |
118 # Look for pyi-makespec.exe |
117 # Look for pyi-makespec.exe |
119 exe = os.path.join(installpath, 'Scripts', 'pyi-makespec.exe') |
118 exe = os.path.join(installpath, "Scripts", "pyi-makespec.exe") |
120 if os.access(exe, os.X_OK): |
119 if os.access(exe, os.X_OK): |
121 exes.append(exe) |
120 exes.append(exe) |
122 return exes |
121 return exes |
123 |
122 |
124 versionSuffixes = ["", "-32", "-64"] |
123 versionSuffixes = ["", "-32", "-64"] |
125 for minorVersion in minorVersions: |
124 for minorVersion in minorVersions: |
126 for versionSuffix in versionSuffixes: |
125 for versionSuffix in versionSuffixes: |
127 versionStr = '{0}.{1}{2}'.format(majorVersion, minorVersion, |
126 versionStr = "{0}.{1}{2}".format( |
128 versionSuffix) |
127 majorVersion, minorVersion, versionSuffix |
|
128 ) |
129 exePaths = getExePath( |
129 exePaths = getExePath( |
130 winreg.HKEY_CURRENT_USER, |
130 winreg.HKEY_CURRENT_USER, |
131 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
131 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, |
|
132 versionStr, |
|
133 ) |
132 for exePath in exePaths: |
134 for exePath in exePaths: |
133 executables.add(exePath) |
135 executables.add(exePath) |
134 |
136 |
135 exePaths = getExePath( |
137 exePaths = getExePath( |
136 winreg.HKEY_LOCAL_MACHINE, |
138 winreg.HKEY_LOCAL_MACHINE, |
137 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr) |
139 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, |
|
140 versionStr, |
|
141 ) |
138 for exePath in exePaths: |
142 for exePath in exePaths: |
139 executables.add(exePath) |
143 executables.add(exePath) |
140 |
144 |
141 # Even on Intel 64-bit machines it's 'AMD64' |
145 # Even on Intel 64-bit machines it's 'AMD64' |
142 if platform.machine() == 'AMD64': |
146 if platform.machine() == "AMD64": |
143 exePaths = getExePath( |
147 exePaths = getExePath( |
144 winreg.HKEY_CURRENT_USER, |
148 winreg.HKEY_CURRENT_USER, |
145 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
149 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, |
|
150 versionStr, |
|
151 ) |
146 for exePath in exePaths: |
152 for exePath in exePaths: |
147 executables.add(exePath) |
153 executables.add(exePath) |
148 |
154 |
149 exePaths = getExePath( |
155 exePaths = getExePath( |
150 winreg.HKEY_LOCAL_MACHINE, |
156 winreg.HKEY_LOCAL_MACHINE, |
151 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr) |
157 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, |
|
158 versionStr, |
|
159 ) |
152 for exePath in exePaths: |
160 for exePath in exePaths: |
153 executables.add(exePath) |
161 executables.add(exePath) |
154 |
162 |
155 if not executables and majorVersion >= 3: |
163 if not executables and majorVersion >= 3: |
156 # check the PATH environment variable if nothing was found |
164 # check the PATH environment variable if nothing was found |
157 # Python 3 only |
165 # Python 3 only |
158 path = Utilities.getEnvironmentEntry('PATH') |
166 path = Utilities.getEnvironmentEntry("PATH") |
159 if path: |
167 if path: |
160 dirs = path.split(os.pathsep) |
168 dirs = path.split(os.pathsep) |
161 for directory in dirs: |
169 for directory in dirs: |
162 for prog in ("pyinstaller.exe", "pyi-makespec.exe"): |
170 for prog in ("pyinstaller.exe", "pyi-makespec.exe"): |
163 exe = os.path.join(directory, prog) |
171 exe = os.path.join(directory, prog) |
164 if os.access(exe, os.X_OK): |
172 if os.access(exe, os.X_OK): |
165 executables.add(exe) |
173 executables.add(exe) |
166 else: |
174 else: |
167 # |
175 # |
168 # Linux, Unix ... |
176 # Linux, Unix ... |
169 pyinstallerScripts = ['pyinstaller', 'pyi-makespec'] |
177 pyinstallerScripts = ["pyinstaller", "pyi-makespec"] |
170 |
178 |
171 # There could be multiple pyinstaller executables in the path |
179 # There could be multiple pyinstaller executables in the path |
172 # e.g. for different python variants |
180 # e.g. for different python variants |
173 path = Utilities.getEnvironmentEntry('PATH') |
181 path = Utilities.getEnvironmentEntry("PATH") |
174 # environment variable not defined |
182 # environment variable not defined |
175 if path is None: |
183 if path is None: |
176 return [] |
184 return [] |
177 |
185 |
178 # step 1: determine possible candidates |
186 # step 1: determine possible candidates |
179 exes = [] |
187 exes = [] |
180 dirs = path.split(os.pathsep) |
188 dirs = path.split(os.pathsep) |
181 for directory in dirs: |
189 for directory in dirs: |
182 for pyinstallerScript in pyinstallerScripts: |
190 for pyinstallerScript in pyinstallerScripts: |
183 exe = os.path.join(directory, pyinstallerScript) |
191 exe = os.path.join(directory, pyinstallerScript) |
184 if os.access(exe, os.X_OK): |
192 if os.access(exe, os.X_OK): |
185 exes.append(exe) |
193 exes.append(exe) |
186 |
194 |
187 # step 2: determine the Python variant |
195 # step 2: determine the Python variant |
188 _exePy3 = set() |
196 _exePy3 = set() |
189 versionArgs = ["-c", "import sys; print(sys.version_info[0])"] |
197 versionArgs = ["-c", "import sys; print(sys.version_info[0])"] |
190 for exe in exes: |
198 for exe in exes: |
191 with open(exe, "r") as f: |
199 with open(exe, "r") as f: |
194 process = QProcess() |
202 process = QProcess() |
195 process.start(program, versionArgs) |
203 process.start(program, versionArgs) |
196 process.waitForFinished(5000) |
204 process.waitForFinished(5000) |
197 # get a QByteArray of the output |
205 # get a QByteArray of the output |
198 versionBytes = process.readAllStandardOutput() |
206 versionBytes = process.readAllStandardOutput() |
199 versionStr = str(versionBytes, encoding='utf-8').strip() |
207 versionStr = str(versionBytes, encoding="utf-8").strip() |
200 if versionStr == "3": |
208 if versionStr == "3": |
201 _exePy3.add(exe) |
209 _exePy3.add(exe) |
202 |
210 |
203 executables = _exePy3 |
211 executables = _exePy3 |
204 |
212 |
205 # sort items, the probably newest topmost |
213 # sort items, the probably newest topmost |
206 executables = list(executables) |
214 executables = list(executables) |
207 executables.sort(reverse=True) |
215 executables.sort(reverse=True) |
208 return executables |
216 return executables |
209 |
217 |
210 |
218 |
211 def _checkProgram(): |
219 def _checkProgram(): |
212 """ |
220 """ |
213 Restricted function to check the availability of pyinstaller. |
221 Restricted function to check the availability of pyinstaller. |
214 |
222 |
215 @return flag indicating availability |
223 @return flag indicating availability |
216 @rtype bool |
224 @rtype bool |
217 """ |
225 """ |
218 global error, exePy3 |
226 global error, exePy3 |
219 |
227 |
220 exePy3 = _findExecutable(3) |
228 exePy3 = _findExecutable(3) |
221 if not exePy3: |
229 if not exePy3: |
222 if Utilities.isWindowsPlatform(): |
230 if Utilities.isWindowsPlatform(): |
223 error = QCoreApplication.translate( |
231 error = QCoreApplication.translate( |
224 "PyInstallerPlugin", |
232 "PyInstallerPlugin", |
225 "The pyinstaller.exe executable could not be found." |
233 "The pyinstaller.exe executable could not be found.", |
226 ) |
234 ) |
227 else: |
235 else: |
228 error = QCoreApplication.translate( |
236 error = QCoreApplication.translate( |
229 "PyInstallerPlugin", |
237 "PyInstallerPlugin", "The pyinstaller executable could not be found." |
230 "The pyinstaller executable could not be found." |
|
231 ) |
238 ) |
232 return False |
239 return False |
233 else: |
240 else: |
234 return True |
241 return True |
235 |
242 |
236 |
243 |
237 class PyInstallerPlugin(QObject): |
244 class PyInstallerPlugin(QObject): |
238 """ |
245 """ |
239 Class implementing the PyInstaller interface plug-in. |
246 Class implementing the PyInstaller interface plug-in. |
240 """ |
247 """ |
|
248 |
241 def __init__(self, ui): |
249 def __init__(self, ui): |
242 """ |
250 """ |
243 Constructor |
251 Constructor |
244 |
252 |
245 @param ui reference to the user interface object |
253 @param ui reference to the user interface object |
246 @type UI.UserInterface |
254 @type UI.UserInterface |
247 """ |
255 """ |
248 super().__init__(ui) |
256 super().__init__(ui) |
249 self.__ui = ui |
257 self.__ui = ui |
250 |
258 |
251 self.__initialize() |
259 self.__initialize() |
252 _checkProgram() |
260 _checkProgram() |
253 |
261 |
254 self.__translator = None |
262 self.__translator = None |
255 self.__loadTranslator() |
263 self.__loadTranslator() |
256 |
264 |
257 def __initialize(self): |
265 def __initialize(self): |
258 """ |
266 """ |
259 Private slot to (re)initialize the plug-in. |
267 Private slot to (re)initialize the plug-in. |
260 """ |
268 """ |
261 self.__projectActs = [] |
269 self.__projectActs = [] |
262 self.__projectSeparator = None |
270 self.__projectSeparator = None |
263 |
271 |
264 def activate(self): |
272 def activate(self): |
265 """ |
273 """ |
266 Public method to activate this plug-in. |
274 Public method to activate this plug-in. |
267 |
275 |
268 @return tuple of None and activation status |
276 @return tuple of None and activation status |
269 @rtype tuple of (None, bool) |
277 @rtype tuple of (None, bool) |
270 """ |
278 """ |
271 global error |
279 global error |
272 |
280 |
273 # There is already an error, don't activate |
281 # There is already an error, don't activate |
274 if error: |
282 if error: |
275 return None, False |
283 return None, False |
276 |
284 |
277 # pyinstaller interface is only activated if it is available |
285 # pyinstaller interface is only activated if it is available |
278 if not _checkProgram(): |
286 if not _checkProgram(): |
279 return None, False |
287 return None, False |
280 |
288 |
281 # clear previous error |
289 # clear previous error |
282 error = "" |
290 error = "" |
283 |
291 |
284 project = ericApp().getObject("Project") |
292 project = ericApp().getObject("Project") |
285 menu = project.getMenu("Packagers") |
293 menu = project.getMenu("Packagers") |
286 if menu: |
294 if menu: |
287 self.__projectSeparator = menu.addSeparator() |
295 self.__projectSeparator = menu.addSeparator() |
288 |
296 |
289 # Execute PyInstaller |
297 # Execute PyInstaller |
290 act = EricAction( |
298 act = EricAction( |
291 self.tr('Execute PyInstaller'), |
299 self.tr("Execute PyInstaller"), |
292 self.tr('Execute Py&Installer'), 0, 0, |
300 self.tr("Execute Py&Installer"), |
293 self, 'packagers_pyinstaller_run') |
301 0, |
|
302 0, |
|
303 self, |
|
304 "packagers_pyinstaller_run", |
|
305 ) |
294 act.setStatusTip( |
306 act.setStatusTip( |
295 self.tr('Generate a distribution package using PyInstaller')) |
307 self.tr("Generate a distribution package using PyInstaller") |
296 act.setWhatsThis(self.tr( |
308 ) |
297 """<b>Execute PyInstaller</b>""" |
309 act.setWhatsThis( |
298 """<p>Generate a distribution package using PyInstaller.""" |
310 self.tr( |
299 """ The command is executed in the project path. All""" |
311 """<b>Execute PyInstaller</b>""" |
300 """ files and directories must be given as absolute paths or""" |
312 """<p>Generate a distribution package using PyInstaller.""" |
301 """ as paths relative to the project path.</p>""" |
313 """ The command is executed in the project path. All""" |
302 )) |
314 """ files and directories must be given as absolute paths or""" |
|
315 """ as paths relative to the project path.</p>""" |
|
316 ) |
|
317 ) |
303 act.triggered.connect(self.__pyinstaller) |
318 act.triggered.connect(self.__pyinstaller) |
304 menu.addAction(act) |
319 menu.addAction(act) |
305 self.__projectActs.append(act) |
320 self.__projectActs.append(act) |
306 |
321 |
307 # Execute pyi-makespec |
322 # Execute pyi-makespec |
308 act = EricAction( |
323 act = EricAction( |
309 self.tr('Make PyInstaller Spec File'), |
324 self.tr("Make PyInstaller Spec File"), |
310 self.tr('Make PyInstaller &Spec File'), 0, 0, |
325 self.tr("Make PyInstaller &Spec File"), |
311 self, 'packagers_pyinstaller_spec') |
326 0, |
312 act.setStatusTip( |
327 0, |
313 self.tr('Generate a spec file to be used by PyInstaller')) |
328 self, |
314 act.setWhatsThis(self.tr( |
329 "packagers_pyinstaller_spec", |
315 """<b>Make PyInstaller Spec File</b>""" |
330 ) |
316 """<p>Generate a spec file to be used by PyInstaller.""" |
331 act.setStatusTip(self.tr("Generate a spec file to be used by PyInstaller")) |
317 """ The command is executed in the project path. All""" |
332 act.setWhatsThis( |
318 """ files and directories must be given as absolute paths or""" |
333 self.tr( |
319 """ as paths relative to the project path.</p>""" |
334 """<b>Make PyInstaller Spec File</b>""" |
320 )) |
335 """<p>Generate a spec file to be used by PyInstaller.""" |
|
336 """ The command is executed in the project path. All""" |
|
337 """ files and directories must be given as absolute paths or""" |
|
338 """ as paths relative to the project path.</p>""" |
|
339 ) |
|
340 ) |
321 act.triggered.connect(self.__pyiMakeSpec) |
341 act.triggered.connect(self.__pyiMakeSpec) |
322 menu.addAction(act) |
342 menu.addAction(act) |
323 self.__projectActs.append(act) |
343 self.__projectActs.append(act) |
324 |
344 |
325 # clean the pyinstaller created directories |
345 # clean the pyinstaller created directories |
326 act = EricAction( |
346 act = EricAction( |
327 self.tr('Clean PyInstaller'), |
347 self.tr("Clean PyInstaller"), |
328 self.tr('&Clean PyInstaller'), 0, 0, |
348 self.tr("&Clean PyInstaller"), |
329 self, 'packagers_pyinstaller_clean') |
349 0, |
330 act.setStatusTip( |
350 0, |
331 self.tr('Remove the PyInstaller created directories')) |
351 self, |
332 act.setWhatsThis(self.tr( |
352 "packagers_pyinstaller_clean", |
333 """<b>Clean PyInstaller</b>""" |
353 ) |
334 """<p>Remove the PyInstaller created directories (dist and""" |
354 act.setStatusTip(self.tr("Remove the PyInstaller created directories")) |
335 """ build). These are subdirectories within the project""" |
355 act.setWhatsThis( |
336 """ path.</p>""" |
356 self.tr( |
337 )) |
357 """<b>Clean PyInstaller</b>""" |
|
358 """<p>Remove the PyInstaller created directories (dist and""" |
|
359 """ build). These are subdirectories within the project""" |
|
360 """ path.</p>""" |
|
361 ) |
|
362 ) |
338 act.triggered.connect(self.__pyinstallerCleanup) |
363 act.triggered.connect(self.__pyinstallerCleanup) |
339 menu.addAction(act) |
364 menu.addAction(act) |
340 self.__projectActs.append(act) |
365 self.__projectActs.append(act) |
341 |
366 |
342 project.addEricActions(self.__projectActs) |
367 project.addEricActions(self.__projectActs) |
343 project.showMenu.connect(self.__projectShowMenu) |
368 project.showMenu.connect(self.__projectShowMenu) |
344 |
369 |
345 return None, True |
370 return None, True |
346 |
371 |
347 def deactivate(self): |
372 def deactivate(self): |
348 """ |
373 """ |
349 Public method to deactivate this plug-in. |
374 Public method to deactivate this plug-in. |
350 """ |
375 """ |
351 menu = ericApp().getObject("Project").getMenu("Packagers") |
376 menu = ericApp().getObject("Project").getMenu("Packagers") |
352 if menu: |
377 if menu: |
353 for act in self.__projectActs: |
378 for act in self.__projectActs: |
354 menu.removeAction(act) |
379 menu.removeAction(act) |
355 if self.__projectSeparator: |
380 if self.__projectSeparator: |
356 menu.removeAction(self.__projectSeparator) |
381 menu.removeAction(self.__projectSeparator) |
357 |
382 |
358 ericApp().getObject("Project").removeEricActions( |
383 ericApp().getObject("Project").removeEricActions(self.__projectActs) |
359 self.__projectActs) |
384 |
360 |
|
361 self.__initialize() |
385 self.__initialize() |
362 |
386 |
363 def __projectShowMenu(self, menuName, menu): |
387 def __projectShowMenu(self, menuName, menu): |
364 """ |
388 """ |
365 Private slot called, when the the project menu or a submenu is |
389 Private slot called, when the the project menu or a submenu is |
366 about to be shown. |
390 about to be shown. |
367 |
391 |
368 @param menuName name of the menu to be shown |
392 @param menuName name of the menu to be shown |
369 @type str |
393 @type str |
370 @param menu reference to the menu |
394 @param menu reference to the menu |
371 @type QMenu |
395 @type QMenu |
372 """ |
396 """ |
373 if menuName == "Packagers": |
397 if menuName == "Packagers": |
374 enable = ( |
398 enable = ericApp().getObject("Project").getProjectLanguage() == "Python3" |
375 ericApp().getObject("Project").getProjectLanguage() == |
|
376 "Python3" |
|
377 ) |
|
378 for act in self.__projectActs: |
399 for act in self.__projectActs: |
379 act.setEnabled(enable) |
400 act.setEnabled(enable) |
380 |
401 |
381 def __loadTranslator(self): |
402 def __loadTranslator(self): |
382 """ |
403 """ |
383 Private method to load the translation file. |
404 Private method to load the translation file. |
384 """ |
405 """ |
385 if self.__ui is not None: |
406 if self.__ui is not None: |
386 loc = self.__ui.getLocale() |
407 loc = self.__ui.getLocale() |
387 if loc and loc != "C": |
408 if loc and loc != "C": |
388 locale_dir = os.path.join(os.path.dirname(__file__), |
409 locale_dir = os.path.join( |
389 "PyInstallerInterface", "i18n") |
410 os.path.dirname(__file__), "PyInstallerInterface", "i18n" |
|
411 ) |
390 translation = "pyinstaller_{0}".format(loc) |
412 translation = "pyinstaller_{0}".format(loc) |
391 translator = QTranslator(None) |
413 translator = QTranslator(None) |
392 loaded = translator.load(translation, locale_dir) |
414 loaded = translator.load(translation, locale_dir) |
393 if loaded: |
415 if loaded: |
394 self.__translator = translator |
416 self.__translator = translator |
395 ericApp().installTranslator(self.__translator) |
417 ericApp().installTranslator(self.__translator) |
396 else: |
418 else: |
397 print("Warning: translation file '{0}' could not be" |
419 print( |
398 " loaded.".format(translation)) |
420 "Warning: translation file '{0}' could not be" |
|
421 " loaded.".format(translation) |
|
422 ) |
399 print("Using default.") |
423 print("Using default.") |
400 |
424 |
401 @pyqtSlot() |
425 @pyqtSlot() |
402 def __pyinstaller(self): |
426 def __pyinstaller(self): |
403 """ |
427 """ |
404 Private slot to execute the pyinstaller command for the current |
428 Private slot to execute the pyinstaller command for the current |
405 project. |
429 project. |
406 """ |
430 """ |
407 project = ericApp().getObject("Project") |
431 project = ericApp().getObject("Project") |
408 majorVersionStr = project.getProjectLanguage() |
432 majorVersionStr = project.getProjectLanguage() |
409 if majorVersionStr == "Python3": |
433 if majorVersionStr == "Python3": |
410 executables = [f for f in exePy3 if |
434 executables = [ |
411 f.endswith(("pyinstaller", "pyinstaller.exe"))] |
435 f for f in exePy3 if f.endswith(("pyinstaller", "pyinstaller.exe")) |
|
436 ] |
412 if not executables: |
437 if not executables: |
413 EricMessageBox.critical( |
438 EricMessageBox.critical( |
414 self.__ui, |
439 self.__ui, |
415 self.tr("pyinstaller"), |
440 self.tr("pyinstaller"), |
416 self.tr("""The pyinstaller executable could not be""" |
441 self.tr( |
417 """ found.""")) |
442 """The pyinstaller executable could not be""" """ found.""" |
|
443 ), |
|
444 ) |
418 return |
445 return |
419 |
446 |
420 # check if all files saved and errorfree before continue |
447 # check if all files saved and errorfree before continue |
421 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
448 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
422 return |
449 return |
423 |
450 |
424 from PyInstallerInterface.PyInstallerConfigDialog import ( |
451 from PyInstallerInterface.PyInstallerConfigDialog import ( |
425 PyInstallerConfigDialog |
452 PyInstallerConfigDialog, |
426 ) |
453 ) |
427 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
454 |
428 dlg = PyInstallerConfigDialog(project, executables, params, |
455 params = project.getData("PACKAGERSPARMS", "PYINSTALLER") |
429 mode="installer") |
456 dlg = PyInstallerConfigDialog( |
|
457 project, executables, params, mode="installer" |
|
458 ) |
430 if dlg.exec() == QDialog.DialogCode.Accepted: |
459 if dlg.exec() == QDialog.DialogCode.Accepted: |
431 args, params, script = dlg.generateParameters() |
460 args, params, script = dlg.generateParameters() |
432 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
461 project.setData("PACKAGERSPARMS", "PYINSTALLER", params) |
433 |
462 |
434 # now do the call |
463 # now do the call |
435 from PyInstallerInterface.PyInstallerExecDialog import ( |
464 from PyInstallerInterface.PyInstallerExecDialog import ( |
436 PyInstallerExecDialog |
465 PyInstallerExecDialog, |
437 ) |
466 ) |
|
467 |
438 dia = PyInstallerExecDialog("pyinstaller") |
468 dia = PyInstallerExecDialog("pyinstaller") |
439 dia.show() |
469 dia.show() |
440 res = dia.start(args, params, project, script) |
470 res = dia.start(args, params, project, script) |
441 if res: |
471 if res: |
442 dia.exec() |
472 dia.exec() |
443 |
473 |
444 @pyqtSlot() |
474 @pyqtSlot() |
445 def __pyiMakeSpec(self): |
475 def __pyiMakeSpec(self): |
446 """ |
476 """ |
447 Private slot to execute the pyi-makespec command for the current |
477 Private slot to execute the pyi-makespec command for the current |
448 project to generate a spec file to be used by pyinstaller. |
478 project to generate a spec file to be used by pyinstaller. |
449 """ |
479 """ |
450 project = ericApp().getObject("Project") |
480 project = ericApp().getObject("Project") |
451 majorVersionStr = project.getProjectLanguage() |
481 majorVersionStr = project.getProjectLanguage() |
452 if majorVersionStr == "Python3": |
482 if majorVersionStr == "Python3": |
453 executables = [f for f in exePy3 if |
483 executables = [ |
454 f.endswith(("pyi-makespec", "pyi-makespec.exe"))] |
484 f for f in exePy3 if f.endswith(("pyi-makespec", "pyi-makespec.exe")) |
|
485 ] |
455 if not executables: |
486 if not executables: |
456 EricMessageBox.critical( |
487 EricMessageBox.critical( |
457 self.__ui, |
488 self.__ui, |
458 self.tr("pyi-makespec"), |
489 self.tr("pyi-makespec"), |
459 self.tr("""The pyi-makespec executable could not be""" |
490 self.tr( |
460 """ found.""")) |
491 """The pyi-makespec executable could not be""" """ found.""" |
|
492 ), |
|
493 ) |
461 return |
494 return |
462 |
495 |
463 # check if all files saved and errorfree before continue |
496 # check if all files saved and errorfree before continue |
464 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
497 if not project.checkAllScriptsDirty(reportSyntaxErrors=True): |
465 return |
498 return |
466 |
499 |
467 from PyInstallerInterface.PyInstallerConfigDialog import ( |
500 from PyInstallerInterface.PyInstallerConfigDialog import ( |
468 PyInstallerConfigDialog |
501 PyInstallerConfigDialog, |
469 ) |
502 ) |
470 params = project.getData('PACKAGERSPARMS', "PYINSTALLER") |
503 |
471 dlg = PyInstallerConfigDialog(project, executables, params, |
504 params = project.getData("PACKAGERSPARMS", "PYINSTALLER") |
472 mode="spec") |
505 dlg = PyInstallerConfigDialog(project, executables, params, mode="spec") |
473 if dlg.exec() == QDialog.DialogCode.Accepted: |
506 if dlg.exec() == QDialog.DialogCode.Accepted: |
474 args, params, script = dlg.generateParameters() |
507 args, params, script = dlg.generateParameters() |
475 project.setData('PACKAGERSPARMS', "PYINSTALLER", params) |
508 project.setData("PACKAGERSPARMS", "PYINSTALLER", params) |
476 |
509 |
477 # now do the call |
510 # now do the call |
478 from PyInstallerInterface.PyInstallerExecDialog import ( |
511 from PyInstallerInterface.PyInstallerExecDialog import ( |
479 PyInstallerExecDialog |
512 PyInstallerExecDialog, |
480 ) |
513 ) |
|
514 |
481 dia = PyInstallerExecDialog("pyinstaller") |
515 dia = PyInstallerExecDialog("pyinstaller") |
482 dia.show() |
516 dia.show() |
483 res = dia.start(args, params, project, script) |
517 res = dia.start(args, params, project, script) |
484 if res: |
518 if res: |
485 dia.exec() |
519 dia.exec() |
486 |
520 |
487 @pyqtSlot() |
521 @pyqtSlot() |
488 def __pyinstallerCleanup(self): |
522 def __pyinstallerCleanup(self): |
489 """ |
523 """ |
490 Private slot to remove the directories created by pyinstaller. |
524 Private slot to remove the directories created by pyinstaller. |
491 """ |
525 """ |
492 project = ericApp().getObject("Project") |
526 project = ericApp().getObject("Project") |
493 |
527 |
494 from PyInstallerInterface.PyInstallerCleanupDialog import ( |
528 from PyInstallerInterface.PyInstallerCleanupDialog import ( |
495 PyInstallerCleanupDialog |
529 PyInstallerCleanupDialog, |
496 ) |
530 ) |
|
531 |
497 dlg = PyInstallerCleanupDialog() |
532 dlg = PyInstallerCleanupDialog() |
498 if dlg.exec() == QDialog.DialogCode.Accepted: |
533 if dlg.exec() == QDialog.DialogCode.Accepted: |
499 removeDirs = dlg.getDirectories() |
534 removeDirs = dlg.getDirectories() |
500 for directory in removeDirs: |
535 for directory in removeDirs: |
501 rd = os.path.join(project.getProjectPath(), directory) |
536 rd = os.path.join(project.getProjectPath(), directory) |