Wed, 10 Apr 2013 22:33:47 +0200
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2087
diff
changeset
|
3 | # Copyright (c) 2006 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module defining common data to be used by all modules. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
10 | from __future__ import unicode_literals # __IGNORE_WARNING__ |
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
11 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import sys |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
13 | import os |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
2087
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
15 | from PyQt4.QtCore import QDir |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
16 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | # names of the various settings objects |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | settingsNameOrganization = "Eric5" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | settingsNameGlobal = "eric5" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | settingsNameRecent = "eric5recent" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | # key names of the various recent entries |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | recentNameMultiProject = "MultiProjects" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | recentNameProject = "Projects" |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | recentNameFiles = "Files" |
1221
291dc0a51947
Added code to the cooperation functions to support IPv6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1162
diff
changeset
|
26 | recentNameHosts = "Hosts6" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
2087
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
28 | configDir = None |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
29 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
882
diff
changeset
|
30 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | def isWindowsPlatform(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | Function to check, if this is a Windows platform. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @return flag indicating Windows platform (boolean) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | return sys.platform.startswith("win") |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
38 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
882
diff
changeset
|
39 | |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
40 | def isMacPlatform(): |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
41 | """ |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
42 | Function to check, if this is a Mac platform. |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
43 | |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
44 | @return flag indicating Mac platform (boolean) |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
45 | """ |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
46 | return sys.platform == "darwin" |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
47 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
882
diff
changeset
|
48 | |
882
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
49 | def isLinuxPlatform(): |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
50 | """ |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
51 | Function to check, if this is a Linux platform. |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
52 | |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
53 | @return flag indicating Linux platform (boolean) |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
54 | """ |
34b86be88bf0
Redid the native file dialog code to be future proof.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
55 | return sys.platform.startswith("linux") |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
56 | |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
57 | |
2087
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
58 | def checkBlacklistedVersions(): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
59 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
60 | Module functions to check for blacklisted versions of the prerequisites. |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
61 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
62 | @return flag indicating good versions were found (boolean) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
63 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
64 | from install import BlackLists, PlatformsBlackLists |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
65 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
66 | # determine the platform dependent black list |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
67 | if isWindowsPlatform(): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
68 | PlatformBlackLists = PlatformsBlackLists["windows"] |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
69 | elif isLinuxPlatform(): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
70 | PlatformBlackLists = PlatformsBlackLists["linux"] |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
71 | else: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
72 | PlatformBlackLists = PlatformsBlackLists["mac"] |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
73 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
74 | # check version of sip |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
75 | try: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
76 | import sipconfig |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
77 | sipVersion = sipconfig.Configuration().sip_version_str |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
78 | # always assume, that snapshots are good |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
79 | if "snapshot" not in sipVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
80 | # check for blacklisted versions |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
81 | for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
82 | if vers == sipVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
83 | print('Sorry, sip version {0} is not compatible with eric5.'\ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
84 | .format(vers)) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
85 | print('Please install another version.') |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
86 | return False |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
87 | except ImportError: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
88 | pass |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
89 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
90 | # check version of PyQt |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
91 | from PyQt4.QtCore import PYQT_VERSION_STR |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
92 | pyqtVersion = PYQT_VERSION_STR |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
93 | # always assume, that snapshots are good |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
94 | if "snapshot" not in pyqtVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
95 | # check for blacklisted versions |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
96 | for vers in BlackLists["PyQt4"] + PlatformBlackLists["PyQt4"]: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
97 | if vers == pyqtVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
98 | print('Sorry, PyQt4 version {0} is not compatible with eric5.'\ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
99 | .format(vers)) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
100 | print('Please install another version.') |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
101 | return False |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
102 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
103 | # check version of QScintilla |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
104 | from PyQt4.Qsci import QSCINTILLA_VERSION_STR |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
105 | scintillaVersion = QSCINTILLA_VERSION_STR |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
106 | # always assume, that snapshots are new enough |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
107 | if "snapshot" not in scintillaVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
108 | # check for blacklisted versions |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
109 | for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
110 | if vers == scintillaVersion: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
111 | print('Sorry, QScintilla2 version {0} is not compatible with eric5.'\ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
112 | .format(vers)) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
113 | print('Please install another version.') |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
114 | return False |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
115 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
116 | return True |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
117 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
118 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
119 | def getConfigDir(): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
120 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
121 | Module function to get the name of the directory storing the config data. |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
122 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
123 | @return directory name of the config dir (string) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
124 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
125 | if configDir is not None and os.path.exists(configDir): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
126 | hp = configDir |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
127 | else: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
128 | if isWindowsPlatform(): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
129 | cdn = "_eric5" |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
130 | else: |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
131 | cdn = ".eric5" |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
132 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
133 | hp = QDir.homePath() |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
134 | dn = QDir(hp) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
135 | dn.mkdir(cdn) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
136 | hp += "/" + cdn |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
137 | return QDir.toNativeSeparators(hp) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
138 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
139 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
140 | def setConfigDir(d): |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
141 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
142 | Module function to set the name of the directory storing the config data. |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
143 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
144 | @param d name of an existing directory (string) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
145 | """ |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
146 | global configDir |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
147 | configDir = os.path.expanduser(d) |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
148 | |
795992a5c561
Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
149 | |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
150 | ################################################################################ |
2573
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
151 | ## functions for searching a Python2/3 interpreter |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
152 | ################################################################################ |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
153 | |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
154 | |
2573
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
155 | def findPythonInterpreters(pyVersion): |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
156 | """ |
2573
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
157 | Module function for searching a Python interpreter. |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
158 | |
2573
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
159 | @param pyVersion major Python version |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
160 | @return list of interpreters found (list of strings) |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
161 | """ |
2573
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
162 | if pyVersion == 2: |
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
163 | winPathList = ["C:\\Python25", "C:\\Python26", "C:\\Python27", "C:\\Python28"] |
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
164 | posixVersionsList = ["2.5", "2.6", "2.7", "2.8"] |
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
165 | else: |
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
166 | winPathList = ["C:\\Python3{0}".format(x) for x in range(5)] |
71837b5366d5
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2525
diff
changeset
|
167 | posixVersionsList = ["3.{0}".format(x) for x in range(5)] |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
168 | posixPathList = ["/usr/bin", "/usr/local/bin"] |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
169 | |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
170 | interpreters = [] |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
171 | if isWindowsPlatform(): |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
172 | # search the interpreters on Windows platforms |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
173 | for path in winPathList: |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
174 | exeList = [ |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
175 | "python.exe", |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
176 | "python{0}.{1}.exe".format(path[-2], path[-1]), |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
177 | ] |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
178 | for exe in exeList: |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
179 | interpreter = os.path.join(path, exe) |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
180 | if os.path.isfile(interpreter): |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
181 | interpreters.append(interpreter) |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
182 | else: |
1363
d650915a903c
Some changes for Mac computers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1221
diff
changeset
|
183 | # search interpreters on Posix and Mac platforms |
1162
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
184 | for path in posixPathList: |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
185 | for version in posixVersionsList: |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
186 | interpreter = os.path.join(path, "python{0}".format(version)) |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
187 | if os.path.isfile(interpreter): |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
188 | interpreters.append(interpreter) |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
189 | |
ab292b7f4f8a
Added code to search for a Python2 interpreter in some known places. If none is found, the user can configure it on the Debugger, Python config page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
945
diff
changeset
|
190 | return interpreters |