PluginCxFreeze.py

Sun, 18 Aug 2013 13:04:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 Aug 2013 13:04:29 +0200
changeset 57
ddf3165e3d62
parent 56
c8a47a8536b0
child 60
8bf1407ebc46
permissions
-rw-r--r--

Some changes to the changes sent by Tobias.

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
54
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
22 error = ""
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
23 except ImportError:
54
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
24 error = QCoreApplication.translate("CxFreezePlugin",
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
25 """Your version of Eric5 is not supported."""
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
26 """ At least version 5.1.0 of Eric5 is needed.""")
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
27
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
28
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
29 import Utilities
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
30
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
31 # 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
32 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
33 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
34 autoactivate = True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
35 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
36 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
37 className = "CxFreezePlugin"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
38 packageName = "CxFreeze"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
39 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
40 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
41 """ 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
42 needsRestart = False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
43 pyqtApi = 2
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
44 # 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
45
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
46 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
47 exePy3 = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
48
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
49 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
50 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
51 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
52
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
53 @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
54 the executable
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
55 """
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 dataList = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
57 data = {
56
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
58 "programEntry": True,
57
ddf3165e3d62 Some changes to the changes sent by Tobias.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 56
diff changeset
59 "header": QCoreApplication.translate("CxFreezePlugin", "Packagers - cx_freeze"),
56
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
60 "exe": 'dummyfreeze',
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
61 "versionCommand": '--version',
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
62 "versionStartsWith": 'dummyfreeze',
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
63 "versionPosition": -1,
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
64 "version": "",
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
65 "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
66 }
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
67
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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76
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
77 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
78 """
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 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
80
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 @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
82 @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
83 """
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
84 # 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
85 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
86 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
87 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
88 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
89 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
90 return []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
91
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
92 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
93 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
94 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
95 # Windows
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
96 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
97 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
98 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
99 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
100 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
101
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115
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 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
117 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
118 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
119 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
120
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 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
122 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
123 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
124 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
125
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
126 # 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
127 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
128 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
129 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
130 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
131 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
132
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 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
134 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
135 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
136 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
137
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 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
139 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
140 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
141 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
142 # 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
143 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
144 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
145 "-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
146 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
147 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
148 "-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
149 # 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
150 # 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
151 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
152 # 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
153 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
154 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
155
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 # 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164
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
165 # 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
166 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
167 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
168 "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
169 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
170 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
171
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 _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
173 _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
174 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
175 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
176 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
177 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
178 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
179 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
180 _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
181 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
182 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
183 _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
184 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
185 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
186
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
187 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
188
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
189 # 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
190 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
191 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
192 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
193
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
194 def _checkProgram():
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
195 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
196 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
197
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
198 @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
199 """
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
200 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
201
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
202 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
203 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
204 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
205 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
206 "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
207 return False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
208 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
209 return True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
210
56
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
211
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
212 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
213 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
214 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
215 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
216 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
217 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
218 Constructor
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 @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
221 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
222 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
223 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
224 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
225 _checkProgram()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
226
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
227 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
228 self.__loadTranslator()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
229
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
230 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
231 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
232 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
233 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
234 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
235
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
236 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
237 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
238 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
239
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
240 @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
241 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
242 global error
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
243
54
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
244 # There is already an error, don't activate
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
245 if error:
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
246 return None, False
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
247
25
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
52
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
342 # check if all files saved and errorfree before continue
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
343 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
344 return
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
345
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
346 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
347 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
348 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
349 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
350 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
351 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
352
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
353 # now do the call
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
354 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
355 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
356 dia.show()
56
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
357 res = dia.start(args, parms, project.ppath,
c8a47a8536b0 filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 54
diff changeset
358 project.pdata["MAINSCRIPT"][0])
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
359 if res:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
360 dia.exec_()

eric ide

mercurial