PluginPyInstaller.py

Sat, 20 Jan 2018 15:58:14 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 20 Jan 2018 15:58:14 +0100
changeset 6
0f0f1598fc4a
parent 5
8c92d66d20e4
child 8
ba5a623378ec
permissions
-rw-r--r--

Continued implementing the PyInstaller interface (implemented the pyi-makespec function).

1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
1 # -*- coding: utf-8 -*-
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
4 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
5
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
6 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
7 Module implementing the PyInstaller interface plug-in.
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
8 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
9
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
10 from __future__ import unicode_literals
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
11 try:
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
12 str = unicode
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
13 except NameError:
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
14 pass
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
15
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 import os
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
17 import platform
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
18 import shutil
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
19
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
20 from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication, QTranslator, \
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
21 QProcess
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
22 from PyQt5.QtWidgets import QDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
23
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
24 from E5Gui import E5MessageBox
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
25 from E5Gui.E5Action import E5Action
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
26 from E5Gui.E5Application import e5App
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
27
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
28 import Utilities
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
29
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
30 # Start-Of-Header
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
31 name = "PyInstaller Plugin"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
32 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
33 autoactivate = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
34 deactivateable = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
35 version = "0.1.0"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
36 className = "PyInstallerPlugin"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
37 packageName = "PyInstaller"
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
38 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
39 longDescription = (
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
40 """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
41 """ 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
42 """ installed via 'pip install PyInstaller'."""
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 needsRestart = False
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
45 pyqtApi = 2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
46 python2Compatible = True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
47 # End-Of-Header
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 error = ""
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 exePy2 = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
52 exePy3 = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
53
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
54
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
55 def exeDisplayDataList():
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 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
58
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
59 @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
60 the executable
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
61 @rtype list of dict
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
62 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
63 dataList = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
64 data = {
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
65 "programEntry": True,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
66 "header": QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
67 "PyInstallerPlugin", "Packagers - PyInstaller"),
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
68 "exe": "dummyExe",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
69 "versionCommand": "--version",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
70 "versionStartsWith": "dummyExe",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
71 "versionPosition": -1,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
72 "version": "",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
73 "versionCleanup": None,
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
74 "versionRe": "^\d",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
75 }
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
76
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
77 if _checkProgram():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
78 for exePath in (exePy2 + exePy3):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
79 data["exe"] = exePath
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
80 data["versionStartsWith"] = ""
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
81 dataList.append(data.copy())
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
82 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
83 dataList.append(data)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
84 return dataList
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
85
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
86
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
87 def _findExecutable(majorVersion):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
88 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
89 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
90
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
91 @param majorVersion major python version
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
92 @type int
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
93 @return names of the executables
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
94 @rtype list of str
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
95 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
96 # Determine Python Version
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
97 if majorVersion == 3:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
98 minorVersions = range(10)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
99 elif majorVersion == 2:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
100 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
101 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
102 return []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
103
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
104 executables = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
105 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
106 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
107 # Windows
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
108 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
109 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
110 import winreg
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
111 except ImportError:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
112 import _winreg as winreg # __IGNORE_WARNING__
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
113
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
114 def getExePath(branch, access, versionStr):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
115 exes = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
116 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
117 software = winreg.OpenKey(branch, 'Software', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
118 python = winreg.OpenKey(software, 'Python', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
119 pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
120 version = winreg.OpenKey(pcore, versionStr, 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
121 installpath = winreg.QueryValue(version, 'InstallPath')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
122 # Look for pyinstaller.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
123 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
124 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
125 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
126 # Look for pyi-makespec.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
127 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
128 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
129 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
130 except (WindowsError, OSError): # __IGNORE_WARNING__
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
131 pass
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
132 return exes
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
133
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
134 versionSuffixes = ["", "-32", "-64"]
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
135 for minorVersion in minorVersions:
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
136 for versionSuffix in versionSuffixes:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
137 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
138 versionSuffix)
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
139 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
140 winreg.HKEY_CURRENT_USER,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
141 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
142 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
143 executables.add(exePath)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
144
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
145 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
146 winreg.HKEY_LOCAL_MACHINE,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
147 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
148 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
149 executables.add(exePath)
2
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 # Even on Intel 64-bit machines it's 'AMD64'
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
152 if platform.machine() == 'AMD64':
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
153 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
154 winreg.HKEY_CURRENT_USER,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
155 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
156 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
157 executables.add(exePath)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
158
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
159 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
160 winreg.HKEY_LOCAL_MACHINE,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
161 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
162 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
163 executables.add(exePath)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
164 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
165 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
166 # Linux, Unix ...
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
167 pyinstallerScripts = ['pyinstaller', 'pyi-makespec']
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
168
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
169 # 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
170 # e.g. for different python variants
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
171 path = Utilities.getEnvironmentEntry('PATH')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
172 # environment variable not defined
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
173 if path is None:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
174 return []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
175
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
176 # step 1: determine possible candidates
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
177 exes = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
178 dirs = path.split(os.pathsep)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
179 for directory in dirs:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
180 for pyinstallerScript in pyinstallerScripts:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
181 exe = os.path.join(directory, pyinstallerScript)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
182 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
183 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
184
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
185 # step 2: determine the Python variant
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
186 _exePy2 = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
187 _exePy3 = set()
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
188 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
189 for exe in exes:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
190 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
191 f = open(exe, "r")
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
192 line0 = f.readline()
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
193 program = line0.replace("#!", "").strip()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
194 process = QProcess()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
195 process.start(program, versionArgs)
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
196 process.waitForFinished(5000)
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
197 # get a QByteArray of the output
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
198 versionBytes = process.readAllStandardOutput()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
199 versionStr = str(versionBytes, encoding='utf-8').strip()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
200 if versionStr == "3":
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
201 _exePy3.add(exe)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
202 else:
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
203 _exePy2.add(exe)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
204 finally:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
205 f.close()
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 executables = _exePy3 if majorVersion == 3 else _exePy2
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
208
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
209 # sort items, the probably newest topmost
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
210 executables = list(executables)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
211 executables.sort(reverse=True)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
212 return executables
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
213
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
214
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
215 def _checkProgram():
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 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
218
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
219 @return flag indicating availability (boolean)
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 global error, exePy2, exePy3
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
222
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
223 exePy2 = _findExecutable(2)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
224 exePy3 = _findExecutable(3)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
225 if (exePy2 + exePy3) == []:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
226 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
227 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
228 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
229 "The pyinstaller.exe executable could not be found."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
230 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
231 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
232 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
233 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
234 "The pyinstaller executable could not be found."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
235 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
236 return False
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
237 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
238 return True
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
239
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
240
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
241 class PyInstallerPlugin(QObject):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
242 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
243 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
244 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
245 def __init__(self, ui):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
246 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
247 Constructor
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
248
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
249 @param ui reference to the user interface object
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
250 @type UI.UserInterface
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
251 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
252 super(PyInstallerPlugin, self).__init__(ui)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
253 self.__ui = ui
3
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.__initialize()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
256 _checkProgram()
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 self.__translator = None
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
259 self.__loadTranslator()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
260
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
261 def __initialize(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
262 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
263 Private slot to (re)initialize the plug-in.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
264 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
265 self.__projectActs = []
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
266
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
267 def activate(self):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
268 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
269 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
270
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
271 @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
272 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
273 global error
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
274
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
275 # There is already an error, don't activate
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
276 if error:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
277 return None, False
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
278
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
279 # 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
280 if not _checkProgram():
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
281 return None, False
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
282
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
283 # clear previous error
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
284 error = ""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
285
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
286 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
287 menu = project.getMenu("Packagers")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
288 if menu:
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"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
300 """ files and directories must be given absolute or"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
301 """ relative to the project directory.</p>"""
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>"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
316 """<p>Generate a spec file to be used by PyInstaller"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
317 """ PyInstaller. The command is executed in the project"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
318 """ path. All files and directories must be given absolute"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
319 """ or relative to the project directory.</p>"""
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"""
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
336 """ path."""
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)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
355
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
356 e5App().getObject("Project").removeE5Actions(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
357 self.__projectActs)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
358
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
359 self.__initialize()
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 def __projectShowMenu(self, menuName, menu):
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 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
364 about to be shown.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
365
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
366 @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
367 @type str
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
368 @param menu reference to the menu
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
369 @type QMenu
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
370 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
371 if menuName == "Packagers":
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
372 enable = e5App().getObject("Project").getProjectLanguage() in \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
373 ["Python", "Python2", "Python3"]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
374 for act in self.__projectActs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
375 act.setEnabled(enable)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
376
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
377 def __loadTranslator(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
378 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
379 Private method to load the translation file.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
380 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
381 if self.__ui is not None:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
382 loc = self.__ui.getLocale()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
383 if loc and loc != "C":
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
384 locale_dir = \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
385 os.path.join(os.path.dirname(__file__),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
386 "PyInstaller", "i18n")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
387 translation = "pyinstaller_{0}".format(loc)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
388 translator = QTranslator(None)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
389 loaded = translator.load(translation, locale_dir)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
390 if loaded:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
391 self.__translator = translator
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
392 e5App().installTranslator(self.__translator)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
393 else:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
394 print("Warning: translation file '{0}' could not be"
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
395 " loaded.".format(translation))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
396 print("Using default.")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
397
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
398 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
399 def __pyinstaller(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
400 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
401 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
402 project.
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
403 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
404 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
405 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
406 if majorVersionStr == "Python3":
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
407 executables = [f for f in exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
408 f.endswith(("pyinstaller", "pyinstaller.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
409 else:
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
410 executables = [f for f in exePy2 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
411 f.endswith(("pyinstaller", "pyinstaller.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
412 if not executables:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
413 E5MessageBox.critical(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
414 self.__ui,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
415 self.tr("pyinstaller"),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
416 self.tr("""The pyinstaller executable could not be found."""))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
417 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
418
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
419 # check if all files saved and errorfree before continue
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
420 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
421 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
422
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
423 from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
424 params = project.getData('PACKAGERSPARMS', "PYINSTALLER")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
425 dlg = PyInstallerConfigDialog(project, executables, params,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
426 mode="installer")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
427 if dlg.exec_() == QDialog.Accepted:
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
428 args, params, script = dlg.generateParameters()
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
429 project.setData('PACKAGERSPARMS', "PYINSTALLER", params)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
430
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
431 # now do the call
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
432 from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
433 dia = PyInstallerExecDialog("pyinstaller")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
434 dia.show()
5
8c92d66d20e4 Continued implementing the PyInstaller interface (implemented the execution dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4
diff changeset
435 res = dia.start(args, params, project, script)
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
436 if res:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
437 dia.exec_()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
438
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
439 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
440 def __pyiMakeSpec(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
441 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
442 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
443 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
444 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
445 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
446 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
447 if majorVersionStr == "Python3":
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
448 executables = [f for f in exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
449 f.endswith(("pyi-makespec", "pyi-makespec.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
450 else:
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
451 executables = [f for f in exePy2 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
452 f.endswith(("pyi-makespec", "pyi-makespec.exe"))]
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
453 if not executables:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
454 E5MessageBox.critical(
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
455 self.__ui,
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
456 self.tr("pyi-makespec"),
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
457 self.tr("""The pyi-makespec executable could not be found."""))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
458 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
459
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
460 # check if all files saved and errorfree before continue
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
461 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
462 return
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
463
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
464 from PyInstaller.PyInstallerConfigDialog import PyInstallerConfigDialog
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
465 params = project.getData('PACKAGERSPARMS', "PYINSTALLER")
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
466 dlg = PyInstallerConfigDialog(project, executables, params,
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
467 mode="spec")
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
468 if dlg.exec_() == QDialog.Accepted:
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
469 args, params, script = dlg.generateParameters()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
470 project.setData('PACKAGERSPARMS', "PYINSTALLER", params)
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
471
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
472 # now do the call
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
473 from PyInstaller.PyInstallerExecDialog import PyInstallerExecDialog
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
474 dia = PyInstallerExecDialog("pyinstaller")
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
475 dia.show()
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
476 res = dia.start(args, params, project, script)
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
477 if res:
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
478 dia.exec_()
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
479
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
480 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
481 def __pyinstallerCleanup(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
482 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
483 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
484 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
485 project = e5App().getObject("Project")
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
486
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
487 from PyInstaller.PyInstallerCleanupDialog import \
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
488 PyInstallerCleanupDialog
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
489 dlg = PyInstallerCleanupDialog()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
490 if dlg.exec_() == QDialog.Accepted:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
491 removeDirs = dlg.getDirectories()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
492 for directory in removeDirs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
493 rd = os.path.join(project.getProjectPath(), directory)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
494 shutil.rmtree(rd, ignore_errors=True)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
495
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
496 #
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
497 # eflag: noqa = M801

eric ide

mercurial