PluginPyInstaller.py

Thu, 27 May 2021 20:28:55 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 27 May 2021 20:28:55 +0200
branch
eric7
changeset 38
fc9ef9dcd51a
parent 35
d9b3cadaf707
permissions
-rw-r--r--

Ported the plug-in to PyQt6 for 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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
15 from PyQt6.QtCore import (
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
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 )
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
18 from PyQt6.QtWidgets import QDialog
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
19
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
20 from EricWidgets import EricMessageBox
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
21 from EricGui.EricAction import EricAction
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
22 from EricWidgets.EricApplication import ericApp
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
31 version = "1.0.0"
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
32 className = "PyInstallerPlugin"
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
33 packageName = "PyInstallerInterface"
1
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:
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
92 minorVersions = range(16)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
93 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
94 return []
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 executables = set()
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
97 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
98 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
99 # Windows
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 try:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
102 import winreg
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
103 except ImportError:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
104 import _winreg as winreg # __IGNORE_WARNING__
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
105
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
106 def getExePath(branch, access, versionStr):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
107 exes = []
35
d9b3cadaf707 Implemented some code simplifications.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
108 with contextlib.suppress(WindowsError, OSError):
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
109 software = winreg.OpenKey(branch, 'Software', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
110 python = winreg.OpenKey(software, 'Python', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
111 pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
112 version = winreg.OpenKey(pcore, versionStr, 0, access)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
113 installpath = winreg.QueryValue(version, 'InstallPath')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
114 # Look for pyinstaller.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
115 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
116 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
117 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
118 # Look for pyi-makespec.exe
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
119 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
120 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
121 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
122 return exes
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
123
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
124 versionSuffixes = ["", "-32", "-64"]
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
125 for minorVersion in minorVersions:
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
126 for versionSuffix in versionSuffixes:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
127 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
128 versionSuffix)
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
129 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
130 winreg.HKEY_CURRENT_USER,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
131 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
132 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
133 executables.add(exePath)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
134
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
135 exePaths = getExePath(
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
136 winreg.HKEY_LOCAL_MACHINE,
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
137 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
138 for exePath in exePaths:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
139 executables.add(exePath)
2
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
140
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
141 # Even on Intel 64-bit machines it's 'AMD64'
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
142 if platform.machine() == 'AMD64':
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
143 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
144 winreg.HKEY_CURRENT_USER,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
145 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
146 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
147 executables.add(exePath)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
148
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
149 exePaths = getExePath(
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
150 winreg.HKEY_LOCAL_MACHINE,
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
151 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
152 for exePath in exePaths:
5109c484bc49 Some fixes for Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1
diff changeset
153 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
154
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
155 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
156 # 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
157 # 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 executables.add(exe)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
166 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
167 #
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
168 # Linux, Unix ...
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
169 pyinstallerScripts = ['pyinstaller', 'pyi-makespec']
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
170
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
171 # 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
172 # e.g. for different python variants
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
173 path = Utilities.getEnvironmentEntry('PATH')
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
174 # environment variable not defined
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
175 if path is None:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
176 return []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
177
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
178 # step 1: determine possible candidates
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
179 exes = []
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
180 dirs = path.split(os.pathsep)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
181 for directory in dirs:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
182 for pyinstallerScript in pyinstallerScripts:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
183 exe = os.path.join(directory, pyinstallerScript)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
184 if os.access(exe, os.X_OK):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
185 exes.append(exe)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
186
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
187 # step 2: determine the Python variant
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
188 _exePy3 = set()
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
189 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
190 for exe in exes:
32
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
191 with open(exe, "r") as f:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
192 line0 = f.readline()
32
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
193 program = line0.replace("#!", "").strip()
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
194 process = QProcess()
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
195 process.start(program, versionArgs)
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
196 process.waitForFinished(5000)
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
197 # get a QByteArray of the output
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
198 versionBytes = process.readAllStandardOutput()
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
199 versionStr = str(versionBytes, encoding='utf-8').strip()
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
200 if versionStr == "3":
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
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
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
203 executables = _exePy3
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
204
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
205 # sort items, the probably newest topmost
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
206 executables = list(executables)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
207 executables.sort(reverse=True)
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
208 return executables
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
209
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
210
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
211 def _checkProgram():
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 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
214
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
215 @return flag indicating availability
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
216 @rtype bool
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
217 """
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
218 global error, exePy3
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
219
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
220 exePy3 = _findExecutable(3)
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
221 if not exePy3:
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
222 if Utilities.isWindowsPlatform():
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
223 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
224 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
225 "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
226 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
227 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
228 error = QCoreApplication.translate(
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
229 "PyInstallerPlugin",
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
230 "The pyinstaller executable could not be found."
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
231 )
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
232 return False
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
233 else:
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
234 return True
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
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
237 class PyInstallerPlugin(QObject):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
238 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
239 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
240 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
241 def __init__(self, ui):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
242 """
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
243 Constructor
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
244
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
245 @param ui reference to the user interface object
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
246 @type UI.UserInterface
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
247 """
35
d9b3cadaf707 Implemented some code simplifications.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
248 super().__init__(ui)
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
249 self.__ui = ui
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
250
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
251 self.__initialize()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
252 _checkProgram()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
253
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
254 self.__translator = None
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
255 self.__loadTranslator()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
256
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
257 def __initialize(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
258 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
259 Private slot to (re)initialize the plug-in.
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 self.__projectActs = []
21
519158f78a41 Added a separator to the project packagers menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
262 self.__projectSeparator = None
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
263
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
264 def activate(self):
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
265 """
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
266 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
267
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
268 @return tuple of None and activation status
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
269 @rtype tuple of (None, bool)
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 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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
284 project = ericApp().getObject("Project")
3
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
290 act = EricAction(
3
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
308 act = EricAction(
3
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
326 act = EricAction(
3
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
342 project.addEricActions(self.__projectActs)
3
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 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
351 menu = ericApp().getObject("Project").getMenu("Packagers")
3
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
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
358 ericApp().getObject("Project").removeEricActions(
3
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 = (
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
375 ericApp().getObject("Project").getProjectLanguage() ==
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
376 "Python3"
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
377 )
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
378 for act in self.__projectActs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
379 act.setEnabled(enable)
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 def __loadTranslator(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
382 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
383 Private method to load the translation file.
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
384 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
385 if self.__ui is not None:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
386 loc = self.__ui.getLocale()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
387 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
388 locale_dir = os.path.join(os.path.dirname(__file__),
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
389 "PyInstallerInterface", "i18n")
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
390 translation = "pyinstaller_{0}".format(loc)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
391 translator = QTranslator(None)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
392 loaded = translator.load(translation, locale_dir)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
393 if loaded:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
394 self.__translator = translator
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
395 ericApp().installTranslator(self.__translator)
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
396 else:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
397 print("Warning: translation file '{0}' could not be"
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
398 " loaded.".format(translation))
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
399 print("Using default.")
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 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
402 def __pyinstaller(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
403 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
404 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
405 project.
1
f7788bc8c08d Implemented support for the programs dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
406 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
407 project = ericApp().getObject("Project")
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
408 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
409 if majorVersionStr == "Python3":
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 exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
411 f.endswith(("pyinstaller", "pyinstaller.exe"))]
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
412 if not executables:
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
413 EricMessageBox.critical(
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
414 self.__ui,
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
415 self.tr("pyinstaller"),
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
416 self.tr("""The pyinstaller executable could not be"""
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
417 """ found."""))
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
418 return
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
419
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
420 # check if all files saved and errorfree before continue
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
421 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
422 return
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
423
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
424 from PyInstallerInterface.PyInstallerConfigDialog import (
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
425 PyInstallerConfigDialog
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
426 )
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
427 params = project.getData('PACKAGERSPARMS', "PYINSTALLER")
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
428 dlg = PyInstallerConfigDialog(project, executables, params,
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
429 mode="installer")
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
430 if dlg.exec() == QDialog.DialogCode.Accepted:
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
431 args, params, script = dlg.generateParameters()
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
432 project.setData('PACKAGERSPARMS', "PYINSTALLER", params)
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
433
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
434 # now do the call
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
435 from PyInstallerInterface.PyInstallerExecDialog import (
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
436 PyInstallerExecDialog
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
437 )
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
438 dia = PyInstallerExecDialog("pyinstaller")
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
439 dia.show()
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
440 res = dia.start(args, params, project, script)
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
441 if res:
32
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
442 dia.exec()
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
443
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
444 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
445 def __pyiMakeSpec(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
446 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
447 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
448 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
449 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
450 project = ericApp().getObject("Project")
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
451 majorVersionStr = project.getProjectLanguage()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
452 if majorVersionStr == "Python3":
4
52f0572b5908 Continued implementing the PyInstaller interface (finished the config dialog).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3
diff changeset
453 executables = [f for f in exePy3 if
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
454 f.endswith(("pyi-makespec", "pyi-makespec.exe"))]
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
455 if not executables:
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
456 EricMessageBox.critical(
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
457 self.__ui,
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
458 self.tr("pyi-makespec"),
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
459 self.tr("""The pyi-makespec executable could not be"""
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
460 """ found."""))
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
461 return
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
462
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
463 # check if all files saved and errorfree before continue
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
464 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
465 return
6
0f0f1598fc4a Continued implementing the PyInstaller interface (implemented the pyi-makespec function).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5
diff changeset
466
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
467 from PyInstallerInterface.PyInstallerConfigDialog import (
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
468 PyInstallerConfigDialog
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
469 )
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
470 params = project.getData('PACKAGERSPARMS', "PYINSTALLER")
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
471 dlg = PyInstallerConfigDialog(project, executables, params,
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
472 mode="spec")
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
473 if dlg.exec() == QDialog.DialogCode.Accepted:
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
474 args, params, script = dlg.generateParameters()
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
475 project.setData('PACKAGERSPARMS', "PYINSTALLER", params)
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
476
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
477 # now do the call
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
478 from PyInstallerInterface.PyInstallerExecDialog import (
28
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
479 PyInstallerExecDialog
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
480 )
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
481 dia = PyInstallerExecDialog("pyinstaller")
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
482 dia.show()
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
483 res = dia.start(args, params, project, script)
3c8dbc198753 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 27
diff changeset
484 if res:
32
efd82d7dea1f Changed calls of exec_() into exec().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 30
diff changeset
485 dia.exec()
3
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 @pyqtSlot()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
488 def __pyinstallerCleanup(self):
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
489 """
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
490 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
491 """
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
492 project = ericApp().getObject("Project")
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
493
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
494 from PyInstallerInterface.PyInstallerCleanupDialog import (
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
495 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
496 )
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
497 dlg = PyInstallerCleanupDialog()
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
498 if dlg.exec() == QDialog.DialogCode.Accepted:
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
499 removeDirs = dlg.getDirectories()
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
500 for directory in removeDirs:
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
501 rd = os.path.join(project.getProjectPath(), directory)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
502 shutil.rmtree(rd, ignore_errors=True)
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
503
38
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
504
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
505 def installDependencies(pipInstall):
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
506 """
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
507 Function to install dependencies of this plug-in.
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
508
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
509 @param pipInstall function to be called with a list of package names.
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
510 @type function
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
511 """
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
512 try:
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
513 import PyInstaller # __IGNORE_WARNING__
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
514 except ImportError:
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
515 pipInstall(["pyinstaller"])
fc9ef9dcd51a Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 35
diff changeset
516
3
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
517 #
eb2d30b4d34e Continued implementing the PyInstaller interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2
diff changeset
518 # eflag: noqa = M801

eric ide

mercurial