PluginCxFreeze.py

Sun, 11 Aug 2013 22:17:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 11 Aug 2013 22:17:02 +0200
changeset 56
c8a47a8536b0
parent 54
d14ff08ea519
child 57
ddf3165e3d62
permissions
-rw-r--r--

filedialog to add distribution dependent files, e.g. *.ui, readme, which are copied after the freeze process

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,
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
59 "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
60 "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
61 "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
62 "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
63 "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
64 "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
65 "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
66 "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
67 }
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
68
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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77
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
78 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
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 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
81
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 @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
83 @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
84 """
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
85 # 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
86 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
87 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
88 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
89 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
90 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
91 return []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
92
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
93 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
94 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
95 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
96 # Windows
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
97 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
98 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
99 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
100 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
101 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
102
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 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116
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 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
118 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
119 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
120 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
121
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 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
123 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
124 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
125 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
126
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
127 # 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
128 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
129 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
130 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
131 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
132 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
133
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 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
135 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
136 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
137 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
138
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 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
140 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
141 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
142 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
143 # 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
144 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
145 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
146 "-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
147 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
148 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
149 "-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
150 # 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
151 # 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
152 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
153 # 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
154 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
155 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
156
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 # 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165
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
166 # 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
167 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
168 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
169 "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
170 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
171 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
172
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 _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
174 _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
175 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
176 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
177 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
178 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
179 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
180 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
181 _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
182 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
183 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
184 _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
185 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
186 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
187
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 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
189
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
190 # 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
191 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
192 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
193 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
194
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
195 def _checkProgram():
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 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
198
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
199 @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
200 """
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
201 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
202
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
203 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
204 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
205 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
206 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
207 "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
208 return False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
209 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
210 return True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
211
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
212
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
213 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
214 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
215 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
216 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
217 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
218 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
219 Constructor
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
220
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
221 @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
222 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
223 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
224 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
225 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
226 _checkProgram()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
227
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
228 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
229 self.__loadTranslator()
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 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
232 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
233 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
234 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
235 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
236
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
237 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
238 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
239 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
240
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
241 @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
242 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
243 global error
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
244
54
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
245 # 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
246 if error:
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
247 return None, False
d14ff08ea519 A little improvement to Tobias' patches.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 52
diff changeset
248
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
249 # 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
250 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
251 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
252
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
253 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
254 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
255 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
256 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
257 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
258 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
259 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
260 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
261 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
262 """<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
263 """<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
264 """ 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
265 """ 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
266 """ 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
267 ))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
268 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
269 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
270 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
271 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
272
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
273 error = ""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
274 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
275
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
276 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
277 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
278 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
279 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
280 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
281 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
282 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
283 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
284 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
285 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
286
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
287 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
288 """
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 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
290 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
291
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 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
293 @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
294 """
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 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
296 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
297 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
298 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
299 ["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
300
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
301 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
302 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
303 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
304 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
305 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
306 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
307 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
308 locale_dir = \
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
309 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
310 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
311 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
312 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
313 if loaded:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
314 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
315 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
316 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
317 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
318 .format(translation))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
319 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
320
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
321 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
322 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
323 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
324 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
325 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
326 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
327 # 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
328 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
329 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
330 self.trUtf8(
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
331 """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
332 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
333 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
334
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
335 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
336 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
337 if exe == []:
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
338 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
339 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
340 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
341 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
342
52
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
343 # 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
344 if not project.checkAllScriptsDirty(reportSyntaxErrors=True):
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
345 return
43d760ff8b3f ask to save modified files before freeze
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 50
diff changeset
346
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
347 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
348 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
349 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
350 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
351 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
352 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
353
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
354 # now do the call
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
355 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
356 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
357 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
358 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
359 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
360 if res:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
361 dia.exec_()

eric ide

mercurial