PluginCxFreeze.py

Mon, 08 Jul 2013 18:40:47 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 08 Jul 2013 18:40:47 +0200
changeset 50
ed85ec1358f0
parent 47
986f27beaad4
child 52
43d760ff8b3f
permissions
-rw-r--r--

Avoid exception if used with Eric 5.0.x; bugfix for the error message.

25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
1 # -*- coding: utf-8 -*-
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
2
36
aa766140aff8 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 34
diff changeset
3 # Copyright (c) 2010 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
4 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
5
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
6 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
7 Module implementing the CxFreeze plugin.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
8 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
9
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
10 from __future__ import unicode_literals # __IGNORE_WARNING__
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
11
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
12 import os
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
13 import platform
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
14
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
15 from PyQt4.QtCore import QObject, QTranslator, QCoreApplication
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
16 from PyQt4.QtGui import QDialog
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
17
50
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
18 try:
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
19 from E5Gui import E5MessageBox
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
20 from E5Gui.E5Action import E5Action
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
21 from E5Gui.E5Application import e5App
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
22 suitable = True
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
23 except ImportError:
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
24 suitable = False
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
26 import Utilities
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
27
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
28 # Start-of-Header
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
29 name = "CxFreeze Plugin"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
30 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
31 autoactivate = True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
32 deactivateable = True
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
33 version = "5.2.0"
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
34 className = "CxFreezePlugin"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
35 packageName = "CxFreeze"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
36 shortDescription = "Show the CxFreeze dialogs."
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
37 longDescription = """This plugin implements the CxFreeze dialogs.""" \
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
38 """ CxFreeze is used to generate a distribution package."""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
39 needsRestart = False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
40 pyqtApi = 2
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
41 # End-of-Header
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
42
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
43 error = ""
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
44 exePy2 = []
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
45 exePy3 = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
46
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
47 def exeDisplayDataList():
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
48 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
49 Public method to support the display of some executable info.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
50
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
51 @return dictionary containing the data to query the presence of
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
52 the executable
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
53 """
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
54 dataList = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
55 data = {
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
56 "programEntry" : True,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
57 "header" : QCoreApplication.translate("CxFreezePlugin",
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
58 "Packagers - cx_freeze"),
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
59 "exe" : 'dummyfreeze',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
60 "versionCommand" : '--version',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
61 "versionStartsWith" : 'dummyfreeze',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
62 "versionPosition" : -1,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
63 "version" : "",
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
64 "versionCleanup" : None,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
65 }
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
66
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
67 if _checkProgram():
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
68 for exePath in (exePy2+exePy3):
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
69 data["exe"] = exePath
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
70 data["versionStartsWith"] = "cxfreeze"
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
71 dataList.append(data.copy())
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
72 else:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
73 dataList.append(data)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
74 return dataList
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
75
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
76 def _findExecutable(majorVersion):
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
77 """
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
78 Restricted function to determine the names of the executable.
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
79
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
80 @param majorVersion major python version of the executables (int)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
81 @return names of the executable (list)
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
82 """
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
83 # Determine Python Version
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
84 if majorVersion == 3:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
85 minorVersions = range(5)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
86 elif majorVersion == 2:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
87 minorVersions = range(5, 9)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
88 else:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
89 return []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
90
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
91 executables = set()
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
92 if Utilities.isWindowsPlatform():
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
93 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
94 # Windows
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
95 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
96 try:
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
97 import winreg
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
98 except ImportError:
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
99 import _winreg as winreg # __IGNORE_WARNING__
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
100
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
101 def getExePath(branch, access, versionStr):
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
102 try:
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
103 software = winreg.OpenKey(branch, 'Software', 0, access)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
104 python = winreg.OpenKey(software, 'Python', 0, access)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
105 pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
106 version = winreg.OpenKey(pcore, versionStr, 0, access)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
107 installpath = winreg.QueryValue(version, 'InstallPath')
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
108 exe = os.path.join(installpath, 'Scripts', 'cxfreeze.bat')
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
109 if os.access(exe, os.X_OK):
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
110 return exe
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
111 except WindowsError: # __IGNORE_WARNING__
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
112 return None
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
113 return None
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
114
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
115 for minorVersion in minorVersions:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
116 versionStr = '{0}.{1}'.format(majorVersion, minorVersion)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
117 exePath = getExePath(winreg.HKEY_CURRENT_USER,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
118 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
119
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
120 if exePath is not None:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
121 executables.add(exePath)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
122 exePath = getExePath(winreg.HKEY_LOCAL_MACHINE,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
123 winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
124
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
125 # Even on Intel 64-bit machines it's 'AMD64'
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
126 if platform.machine() == 'AMD64':
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
127 if exePath is not None:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
128 executables.add(exePath)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
129 exePath = getExePath(winreg.HKEY_CURRENT_USER,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
130 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
131
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
132 if exePath is not None:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
133 executables.add(exePath)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
134 exePath = getExePath(winreg.HKEY_LOCAL_MACHINE,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
135 winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
136
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
137 if exePath is not None:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
138 executables.add(exePath)
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
139 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
140 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
141 # Linux, Unix ...
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
142 cxfreezeScript = 'cxfreeze'
33
2a3b4b7a633f Enhanced the algorithm to determine the cxfreeze executable on non-Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 32
diff changeset
143 scriptSuffixes = ["",
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
144 "-python{0}".format(majorVersion)]
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
145 for minorVersion in minorVersions:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
146 scriptSuffixes.append(
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
147 "-python{0}.{1}".format(majorVersion, minorVersion))
30
153f0acb2ebb Corrected some more stuff in the main plug-in file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 28
diff changeset
148 # There could be multiple cxfreeze executables in the path
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
149 # e.g. for different python variants
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
150 path = Utilities.getEnvironmentEntry('PATH')
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
151 # environment variable not defined
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
152 if path is None:
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
153 return []
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
154
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
155 # step 1: determine possible candidates
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
156 exes = []
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
157 dirs = path.split(os.pathsep)
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
158 for dir in dirs:
33
2a3b4b7a633f Enhanced the algorithm to determine the cxfreeze executable on non-Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 32
diff changeset
159 for suffix in scriptSuffixes:
2a3b4b7a633f Enhanced the algorithm to determine the cxfreeze executable on non-Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 32
diff changeset
160 exe = os.path.join(dir, cxfreezeScript + suffix)
2a3b4b7a633f Enhanced the algorithm to determine the cxfreeze executable on non-Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 32
diff changeset
161 if os.access(exe, os.X_OK):
2a3b4b7a633f Enhanced the algorithm to determine the cxfreeze executable on non-Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 32
diff changeset
162 exes.append(exe)
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
163
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
164 # step 2: determine the Python variant
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
165 if Utilities.isMacPlatform():
41
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
166 checkStrings = ["Python.framework/Versions/3".lower(),
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
167 "python3"]
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
168 else:
41
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
169 checkStrings = ["python3"]
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
170
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
171 _exePy2 = set()
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
172 _exePy3 = set()
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
173 for exe in exes:
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
174 try:
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
175 f = open(exe, "r")
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
176 line0 = f.readline()
41
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
177 for checkStr in checkStrings:
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
178 if checkStr in line0.lower():
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
179 _exePy3.add(exe)
41
394efa0e059c Fixed an issue locating the cxfreeze executable on Mac OS X and the list of init-scripts containing a .py extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
180 break
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
181 else:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
182 _exePy2.add(exe)
28
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
183 finally:
bbcf4437e32a Fixed the algorithm searching for the right cxfreeze executable in the presence of multiple installations for different Python versions..
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
184 f.close()
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
185
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
186 executables = _exePy3 if majorVersion == 3 else _exePy2
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
187
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
188 # sort items, the probably newest topmost
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
189 executables = list(executables)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
190 executables.sort(reverse=True)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
191 return executables
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
192
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
193 def _checkProgram():
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
194 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
195 Restricted function to check the availability of cxfreeze.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
196
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
197 @return flag indicating availability (boolean)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
198 """
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
199 global error, exePy2, exePy3
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
200
50
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
201 if not suitable:
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
202 error = QCoreApplication.translate("CxFreezePlugin", """Your version of Eric5 is not supported.
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
203 At least version 5.1.0 of Eric5 is needed.""")
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
204 return False
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
205
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
206 exePy2 = _findExecutable(2)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
207 exePy3 = _findExecutable(3)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
208 if (exePy2+exePy3) == []:
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
209 error = QCoreApplication.translate("CxFreezePlugin",
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
210 "The cxfreeze executable could not be found.")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
211 return False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
212 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
213 return True
50
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
214 _checkProgram()
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
215
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
216 class CxFreezePlugin(QObject):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
217 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
218 Class implementing the CxFreeze plugin.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
219 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
220 def __init__(self, ui):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
221 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
222 Constructor
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
223
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
224 @param ui reference to the user interface object (UI.UserInterface)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
225 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
226 QObject.__init__(self, ui)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
227 self.__ui = ui
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
228 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
229 _checkProgram()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
230
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
231 self.__translator = None
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
232 self.__loadTranslator()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
233
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
234 def __initialize(self):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
235 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
236 Private slot to (re)initialize the plugin.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
237 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
238 self.__projectAct = None
50
ed85ec1358f0 Avoid exception if used with Eric 5.0.x; bugfix for the error message.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 47
diff changeset
239
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
240 def activate(self):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
241 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
242 Public method to activate this plugin.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
243
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
244 @return tuple of None and activation status (boolean)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
245 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
246 global error
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
247
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
248 # cxfreeze is only activated if it is available
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
249 if not _checkProgram():
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
250 return None, False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
251
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
252 project = e5App().getObject("Project")
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
253 menu = project.getMenu("Packagers")
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
254 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
255 self.__projectAct = E5Action(self.trUtf8('Use cx_freeze'),
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
256 self.trUtf8('Use cx_&freeze'), 0, 0,
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
257 self, 'packagers_cxfreeze')
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
258 self.__projectAct.setStatusTip(
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
259 self.trUtf8('Generate a distribution package using cx_freeze'))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
260 self.__projectAct.setWhatsThis(self.trUtf8(
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
261 """<b>Use cx_freeze</b>"""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
262 """<p>Generate a distribution package using cx_freeze."""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
263 """ The command is executed in the project path. All"""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
264 """ files and directories must be given absolute or"""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
265 """ relative to the project directory.</p>"""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
266 ))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
267 self.__projectAct.triggered[()].connect(self.__cxfreeze)
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
268 project.addE5Actions([self.__projectAct])
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
269 menu.addAction(self.__projectAct)
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
270 project.showMenu.connect(self.__projectShowMenu)
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
271
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
272 error = ""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
273 return None, True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
274
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
275 def deactivate(self):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
276 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
277 Public method to deactivate this plugin.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
278 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
279 menu = e5App().getObject("Project").getMenu("Packagers")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
280 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
281 if self.__projectAct:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
282 menu.removeAction(self.__projectAct)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
283 e5App().getObject("Project").removeE5Actions([self.__projectAct])
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
284 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
285
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
286 def __projectShowMenu(self, menuName, menu):
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
287 """
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
288 Private slot called, when the the project menu or a submenu is
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
289 about to be shown.
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
290
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
291 @param menuName name of the menu to be shown (string)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
292 @param menu reference to the menu (QMenu)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
293 """
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
294 if menuName == "Packagers":
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
295 if self.__projectAct is not None:
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
296 self.__projectAct.setEnabled(
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
297 e5App().getObject("Project").getProjectLanguage() in \
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
298 ["Python", "Python2", "Python3"])
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
299
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
300 def __loadTranslator(self):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
301 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
302 Private method to load the translation file.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
303 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
304 if self.__ui is not None:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
305 loc = self.__ui.getLocale()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
306 if loc and loc != "C":
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
307 locale_dir = \
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
308 os.path.join(os.path.dirname(__file__), "CxFreeze", "i18n")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
309 translation = "cxfreeze_{0}".format(loc)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
310 translator = QTranslator(None)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
311 loaded = translator.load(translation, locale_dir)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
312 if loaded:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
313 self.__translator = translator
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
314 e5App().installTranslator(self.__translator)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
315 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
316 print("Warning: translation file '{0}' could not be loaded."\
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
317 .format(translation))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
318 print("Using default.")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
319
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
320 def __cxfreeze(self):
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
321 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
322 Private slot to handle the cxfreeze execution.
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
323 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
324 project = e5App().getObject("Project")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
325 if len(project.pdata["MAINSCRIPT"]) == 0:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
326 # no main script defined
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
327 E5MessageBox.critical(None,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
328 self.trUtf8("cxfreeze"),
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
329 self.trUtf8(
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
330 """There is no main script defined for the current project."""),
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
331 E5MessageBox.StandardButtons(E5MessageBox.Abort))
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
332 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
333
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
334 majorVersionStr = project.getProjectLanguage()
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
335 exe = {"Python": exePy2, "Python2": exePy2, "Python3": exePy3}.get(majorVersionStr)
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
336 if exe == []:
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
337 E5MessageBox.critical(None,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
338 self.trUtf8("cxfreeze"),
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
339 self.trUtf8("""The cxfreeze executable could not be found."""))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
340 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
341
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
342 from CxFreeze.CxfreezeConfigDialog import CxfreezeConfigDialog
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
343 parms = project.getData('PACKAGERSPARMS', "CXFREEZE")
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
344 dlg = CxfreezeConfigDialog(project, exe, parms)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
345 if dlg.exec_() == QDialog.Accepted:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
346 args, parms = dlg.generateParameters()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
347 project.setData('PACKAGERSPARMS', "CXFREEZE", parms)
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
348
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
349 # now do the call
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
350 from CxFreeze.CxfreezeExecDialog import CxfreezeExecDialog
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
351 dia = CxfreezeExecDialog("cxfreeze")
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
352 dia.show()
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
353 res = dia.start(args,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
354 os.path.join(project.ppath, project.pdata["MAINSCRIPT"][0]))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
355 if res:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
356 dia.exec_()

eric ide

mercurial