PluginCxFreeze.py

Sun, 07 Jul 2013 20:40:48 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 07 Jul 2013 20:40:48 +0200
changeset 47
986f27beaad4
parent 44
8b51b5efd1ae
child 50
ed85ec1358f0
permissions
-rw-r--r--

Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
For complete list see ChangeLog

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
39
27dcfe29985b Changed usage of QMessageBox and QFileDialog to the eric5 equivalents.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 37
diff changeset
18 from E5Gui import E5MessageBox
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
19 from E5Gui.E5Action import E5Action
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
20 from E5Gui.E5Application import e5App
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
21
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
22 import Utilities
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
23
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
24 # 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
25 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
26 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
27 autoactivate = True
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
28 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
29 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
30 className = "CxFreezePlugin"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
31 packageName = "CxFreeze"
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
32 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
33 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
34 """ 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
35 needsRestart = False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
36 pyqtApi = 2
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
37 # 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
38
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
39 error = ""
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
40 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
41 exePy3 = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
42
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
43 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
44 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
45 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
46
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
47 @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
48 the executable
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
49 """
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
50 dataList = []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
51 data = {
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
52 "programEntry" : True,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
53 "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
54 "Packagers - cx_freeze"),
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
55 "exe" : 'dummyfreeze',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
56 "versionCommand" : '--version',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
57 "versionStartsWith" : 'dummyfreeze',
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
58 "versionPosition" : -1,
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
59 "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
60 "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
61 }
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
62
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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71
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
72 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
73 """
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 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
75
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 @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
77 @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
78 """
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
79 # 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
80 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
81 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
82 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
83 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
84 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
85 return []
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
86
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
87 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
88 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
89 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
90 # Windows
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
91 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
92 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
93 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
94 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
95 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
96
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
97 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
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 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110
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 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
112 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
113 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
114 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
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 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
117 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
118 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
119 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
120
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
121 # 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
122 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
123 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
124 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
125 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
126 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
127
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_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
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)
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
135 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
136 #
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
137 # 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
138 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
139 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
140 "-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
141 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
142 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
143 "-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
144 # 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
145 # 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
146 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
147 # 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
148 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
149 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
150
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 # 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159
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
160 # 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
161 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
162 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
163 "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
164 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
165 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
166
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
167 _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
168 _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
169 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
170 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
171 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
172 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
173 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
174 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
175 _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
176 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
177 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
178 _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
179 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
180 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
181
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 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
183
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
184 # 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
185 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
186 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
187 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
188
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
189 def _checkProgram():
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
190 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
191 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
192
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
193 @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
194 """
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
195 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
196
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
197 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
198 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
199 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
200 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
201 "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
202 return False
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
203 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
204 return 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
205
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
206
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
207 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
208 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
209 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
210 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
211 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
212 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
213 Constructor
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 @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
216 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
217 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
218 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
219 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
220 _checkProgram()
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 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
223 self.__loadTranslator()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
224
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
225 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
226 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
227 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
228 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
229 self.__projectAct = None
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 activate(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 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
234
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
235 @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
236 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
237 global error
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 # 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
240 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
241 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
242
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
243 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
244 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
245 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
246 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
247 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
248 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
249 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
250 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
251 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
252 """<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
253 """<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
254 """ 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
255 """ 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
256 """ 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
257 ))
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.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
259 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
260 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
261 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
262
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
263 error = ""
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
264 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
265
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
266 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
267 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
268 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
269 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
270 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
271 if menu:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
272 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
273 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
274 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
275 self.__initialize()
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
276
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
277 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
278 """
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
279 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
280 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
281
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
282 @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
283 @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
284 """
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
285 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
286 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
287 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
288 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
289 ["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
290
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
291 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
292 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
293 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
294 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
295 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
296 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
297 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
298 locale_dir = \
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
299 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
300 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
301 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
302 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
303 if loaded:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
304 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
305 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
306 else:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
307 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
308 .format(translation))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
309 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
310
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
311 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
312 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
313 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
314 """
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
315 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
316 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
317 # 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
318 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
319 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
320 self.trUtf8(
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
321 """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
322 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
323 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
324
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
325 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
326 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
327 if exe == []:
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("""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
331 return
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
332
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
333 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
334 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
335 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
336 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
337 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
338 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
339
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
340 # now do the call
37
94949c60ef54 Modified the code to do lazy import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 36
diff changeset
341 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
342 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
343 dia.show()
47
986f27beaad4 Py2 compatibility, freeze script based on project language, filedialog for icons, some PEP8.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 44
diff changeset
344 res = dia.start(args,
25
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
345 os.path.join(project.ppath, project.pdata["MAINSCRIPT"][0]))
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
346 if res:
737c623c90df Fixed the cxfreeze search algorithm to check a per user install as well.
detlev@die-offenbachs.de
parents: 24
diff changeset
347 dia.exec_()

eric ide

mercurial