PluginPyInstaller.py

Thu, 27 May 2021 19:23:58 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 27 May 2021 19:23:58 +0200
branch
eric7
changeset 37
9ecfea29a47c
parent 35
d9b3cadaf707
child 38
fc9ef9dcd51a
permissions
-rw-r--r--

Created new branch <eric7>.

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

eric ide

mercurial