46 defaultMacAppBundlePath = "/Applications" |
46 defaultMacAppBundlePath = "/Applications" |
47 macAppBundleName = "eric6.app" |
47 macAppBundleName = "eric6.app" |
48 macAppBundlePath = "/Applications" |
48 macAppBundlePath = "/Applications" |
49 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format( |
49 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format( |
50 sys.exec_prefix) |
50 sys.exec_prefix) |
|
51 pyqtVariant = "" |
51 |
52 |
52 # Define blacklisted versions of the prerequisites |
53 # Define blacklisted versions of the prerequisites |
53 BlackLists = { |
54 BlackLists = { |
54 "sip": ["4.11", "4.12.3"], |
55 "sip": ["4.11", "4.12.3"], |
|
56 "PyQt4": [], |
55 "PyQt5": [], |
57 "PyQt5": [], |
56 "QScintilla2": [], |
58 "QScintilla2": [], |
57 } |
59 } |
58 PlatformsBlackLists = { |
60 PlatformsBlackLists = { |
59 "windows": { |
61 "windows": { |
60 "sip": [], |
62 "sip": [], |
|
63 "PyQt4": [], |
61 "PyQt5": [], |
64 "PyQt5": [], |
62 "QScintilla2": [], |
65 "QScintilla2": [], |
63 }, |
66 }, |
64 |
67 |
65 "linux": { |
68 "linux": { |
66 "sip": [], |
69 "sip": [], |
|
70 "PyQt4": [], |
67 "PyQt5": [], |
71 "PyQt5": [], |
68 "QScintilla2": [], |
72 "QScintilla2": [], |
69 }, |
73 }, |
70 |
74 |
71 "mac": { |
75 "mac": { |
72 "sip": [], |
76 "sip": [], |
|
77 "PyQt4": [], |
73 "PyQt5": [], |
78 "PyQt5": [], |
74 "QScintilla2": [], |
79 "QScintilla2": [], |
75 }, |
80 }, |
76 } |
81 } |
77 |
82 |
164 " parts of eric6.") |
169 " parts of eric6.") |
165 |
170 |
166 exit(rcode) |
171 exit(rcode) |
167 |
172 |
168 |
173 |
|
174 def determinePyQtVariant(): |
|
175 """ |
|
176 Module function to determine the PyQt variant to be used. |
|
177 """ |
|
178 global pyqtVariant |
|
179 |
|
180 try: |
|
181 import PyQt5 # __IGNORE_WARNING__ |
|
182 pyqtVariant = "PyQt5" |
|
183 except ImportError: |
|
184 try: |
|
185 import PyQt4 # __IGNORE_WARNING__ |
|
186 pyqtVariant = "PyQt4" |
|
187 except ImportError: |
|
188 pyqtVariant = "" |
|
189 |
|
190 |
169 def initGlobals(): |
191 def initGlobals(): |
170 """ |
192 """ |
171 Module function to set the values of globals that need more than a |
193 Module function to set the values of globals that need more than a |
172 simple assignment. |
194 simple assignment. |
173 """ |
195 """ |
174 global platBinDir, modDir, pyModDir, apisDir |
196 global platBinDir, modDir, pyModDir, apisDir, pyqtVariant |
175 |
197 |
176 if sys.platform.startswith("win"): |
198 if sys.platform.startswith("win"): |
177 platBinDir = sys.exec_prefix |
199 platBinDir = sys.exec_prefix |
178 if platBinDir.endswith("\\"): |
200 if platBinDir.endswith("\\"): |
179 platBinDir = platBinDir[:-1] |
201 platBinDir = platBinDir[:-1] |
181 platBinDir = "/usr/local/bin" |
203 platBinDir = "/usr/local/bin" |
182 |
204 |
183 modDir = distutils.sysconfig.get_python_lib(True) |
205 modDir = distutils.sysconfig.get_python_lib(True) |
184 pyModDir = modDir |
206 pyModDir = modDir |
185 |
207 |
186 pyqtDataDir = os.path.join(modDir, "PyQt5") |
208 pyqtDataDir = os.path.join(modDir, pyqtVariant) |
187 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
209 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
188 # it's the installer |
210 # it's the installer |
189 qtDataDir = pyqtDataDir |
211 qtDataDir = pyqtDataDir |
190 else: |
212 else: |
191 try: |
213 try: |
192 from PyQt5.QtCore import QLibraryInfo |
214 if pyqtVariant == "PyQt4": |
|
215 from PyQt4.QtCore import QLibraryInfo |
|
216 else: |
|
217 from PyQt5.QtCore import QLibraryInfo |
193 qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath) |
218 qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath) |
194 except ImportError: |
219 except ImportError: |
195 qtDataDir = None |
220 qtDataDir = None |
196 if qtDataDir: |
221 if qtDataDir: |
197 apisDir = os.path.join(qtDataDir, "qsci", "api") |
222 apisDir = os.path.join(qtDataDir, "qsci", "api") |
928 except ImportError as msg: |
953 except ImportError as msg: |
929 print('Your Python installation is missing the XML module.') |
954 print('Your Python installation is missing the XML module.') |
930 print('Please install it and try again.') |
955 print('Please install it and try again.') |
931 exit(5) |
956 exit(5) |
932 |
957 |
|
958 if pyqtVariant == "PyQt4": |
|
959 try: |
|
960 from PyQt4.QtCore import qVersion |
|
961 except ImportError as msg: |
|
962 print('Sorry, please install PyQt5 or PyQt4.') |
|
963 print('Error: {0}'.format(msg)) |
|
964 exit(1) |
|
965 print("Found PyQt4") |
|
966 else: |
|
967 try: |
|
968 from PyQt5.QtCore import qVersion |
|
969 except ImportError as msg: |
|
970 print('Sorry, please install PyQt5 or PyQt4.') |
|
971 print('Error: {0}'.format(msg)) |
|
972 exit(1) |
|
973 print("Found PyQt5") |
|
974 |
933 try: |
975 try: |
934 from PyQt5.QtCore import qVersion |
976 if pyqtVariant == "PyQt4": |
935 except ImportError as msg: |
977 from PyQt4 import Qsci # __IGNORE_WARNING__ |
936 print('Sorry, please install PyQt5.') |
978 else: |
937 print('Error: {0}'.format(msg)) |
979 from PyQt5 import Qsci # __IGNORE_WARNING__ |
938 exit(1) |
|
939 print("Found PyQt5") |
|
940 |
|
941 try: |
|
942 from PyQt5 import Qsci # __IGNORE_WARNING__ |
|
943 |
|
944 except ImportError as msg: |
980 except ImportError as msg: |
945 print("Sorry, please install QScintilla2 and") |
981 print("Sorry, please install QScintilla2 and") |
946 print("its PyQt5 wrapper.") |
982 print("its PyQt5/PyQt4 wrapper.") |
947 print('Error: {0}'.format(msg)) |
983 print('Error: {0}'.format(msg)) |
948 exit(1) |
984 exit(1) |
949 print("Found QScintilla2") |
985 print("Found QScintilla2") |
950 |
986 |
|
987 if pyqtVariant == "PyQt4": |
|
988 impModulesList = [ |
|
989 "PyQt4.QtGui", "PyQt4.QtNetwork", "PyQt4.QtSql", |
|
990 "PyQt4.QtSvg", "PyQt4.QtWebKit", |
|
991 ] |
|
992 else: |
|
993 impModulesList = [ |
|
994 "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport", |
|
995 "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWebKit", |
|
996 "PyQt5.QtWebKitWidgets", "PyQt5.QtWidgets", |
|
997 ] |
951 modulesOK = True |
998 modulesOK = True |
952 for impModule in [ |
999 for impModule in impModulesList: |
953 "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport", |
|
954 "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWebKit", |
|
955 "PyQt5.QtWebKitWidgets", "PyQt5.QtWidgets", |
|
956 ]: |
|
957 name = impModule.split(".")[1] |
1000 name = impModule.split(".")[1] |
958 try: |
1001 try: |
959 __import__(impModule) |
1002 __import__(impModule) |
960 print("Found", name) |
1003 print("Found", name) |
961 except ImportError as msg: |
1004 except ImportError as msg: |
974 PlatformBlackLists = PlatformsBlackLists["mac"] |
1017 PlatformBlackLists = PlatformsBlackLists["mac"] |
975 |
1018 |
976 # check version of Qt |
1019 # check version of Qt |
977 qtMajor = int(qVersion().split('.')[0]) |
1020 qtMajor = int(qVersion().split('.')[0]) |
978 qtMinor = int(qVersion().split('.')[1]) |
1021 qtMinor = int(qVersion().split('.')[1]) |
979 if qtMajor < 5 or (qtMajor == 3 and qtMinor < 6): |
1022 if qtMajor < 4 or \ |
980 print('Sorry, you must have Qt version 5.3.0 or higher.') |
1023 (qtMajor == 4 and qtMinor < 8) or \ |
|
1024 (qtMajor == 5 and qtMinor < 3): |
|
1025 print('Sorry, you must have Qt version 4.8.0 or better or') |
|
1026 print('5.3.0 or better.') |
981 exit(2) |
1027 exit(2) |
982 print("Qt Version: {0}".format(qVersion())) |
1028 print("Qt Version: {0}".format(qVersion())) |
983 |
1029 |
984 # check version of sip |
1030 # check version of sip |
985 try: |
1031 try: |
1008 exit(3) |
1054 exit(3) |
1009 except (ImportError, AttributeError): |
1055 except (ImportError, AttributeError): |
1010 pass |
1056 pass |
1011 |
1057 |
1012 # check version of PyQt |
1058 # check version of PyQt |
1013 from PyQt5.QtCore import PYQT_VERSION_STR |
1059 if pyqtVariant == "PyQt4": |
|
1060 from PyQt4.QtCore import PYQT_VERSION_STR |
|
1061 else: |
|
1062 from PyQt5.QtCore import PYQT_VERSION_STR |
1014 pyqtVersion = PYQT_VERSION_STR |
1063 pyqtVersion = PYQT_VERSION_STR |
1015 # always assume, that snapshots are new enough |
1064 # always assume, that snapshots are new enough |
1016 if "snapshot" not in pyqtVersion: |
1065 if "snapshot" not in pyqtVersion: |
1017 while pyqtVersion.count('.') < 2: |
1066 while pyqtVersion.count('.') < 2: |
1018 pyqtVersion += '.0' |
1067 pyqtVersion += '.0' |
1019 (maj, min, pat) = pyqtVersion.split('.') |
1068 (maj, min, pat) = pyqtVersion.split('.') |
1020 maj = int(maj) |
1069 maj = int(maj) |
1021 min = int(min) |
1070 min = int(min) |
1022 pat = int(pat) |
1071 pat = int(pat) |
1023 if maj < 5 or (maj == 5 and min < 3): |
1072 if maj < 4 or \ |
1024 print('Sorry, you must have PyQt 5.3.0 or higher or' |
1073 (maj == 4 and min < 10) or \ |
|
1074 (maj == 5 and min < 3): |
|
1075 print('Sorry, you must have PyQt 4.10.0 or better or') |
|
1076 print('PyQt 5.3.0 or better or' |
1025 ' a recent snapshot release.') |
1077 ' a recent snapshot release.') |
1026 exit(4) |
1078 exit(4) |
1027 # check for blacklisted versions |
1079 # check for blacklisted versions |
1028 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]: |
1080 for vers in BlackLists[pyqtVariant] + PlatformBlackLists[pyqtVariant]: |
1029 if vers == pyqtVersion: |
1081 if vers == pyqtVersion: |
1030 print('Sorry, PyQt5 version {0} is not compatible with eric6.' |
1082 print('Sorry, PyQt version {0} is not compatible with eric6.' |
1031 .format(vers)) |
1083 .format(vers)) |
1032 print('Please install another version.') |
1084 print('Please install another version.') |
1033 exit(4) |
1085 exit(4) |
1034 print("PyQt Version: ", pyqtVersion) |
1086 print("PyQt Version: ", pyqtVersion) |
1035 |
1087 |
1036 # check version of QScintilla |
1088 # check version of QScintilla |
1037 from PyQt5.Qsci import QSCINTILLA_VERSION_STR |
1089 if pyqtVariant == "PyQt4": |
|
1090 from PyQt4.Qsci import QSCINTILLA_VERSION_STR |
|
1091 else: |
|
1092 from PyQt5.Qsci import QSCINTILLA_VERSION_STR |
1038 scintillaVersion = QSCINTILLA_VERSION_STR |
1093 scintillaVersion = QSCINTILLA_VERSION_STR |
1039 # always assume, that snapshots are new enough |
1094 # always assume, that snapshots are new enough |
1040 if "snapshot" not in scintillaVersion: |
1095 if "snapshot" not in scintillaVersion: |
1041 while scintillaVersion.count('.') < 2: |
1096 while scintillaVersion.count('.') < 2: |
1042 scintillaVersion += '.0' |
1097 scintillaVersion += '.0' |
1060 print("QScintilla Version: ", QSCINTILLA_VERSION_STR) |
1115 print("QScintilla Version: ", QSCINTILLA_VERSION_STR) |
1061 print("All dependencies ok.") |
1116 print("All dependencies ok.") |
1062 print() |
1117 print() |
1063 |
1118 |
1064 |
1119 |
|
1120 # TODO: PyQt4 |
1065 def compileUiFiles(): |
1121 def compileUiFiles(): |
1066 """ |
1122 """ |
1067 Compile the .ui files to Python sources. |
1123 Compile the .ui files to Python sources. |
1068 """ # __IGNORE_WARNING__ |
1124 """ # __IGNORE_WARNING__ |
1069 global sourceDir |
1125 global sourceDir |
1070 try: |
1126 try: |
1071 from PyQt5.uic import compileUiDir |
1127 if pyqtVariant == "PyQt4": |
|
1128 from PyQt4.uic import compileUiDir |
|
1129 else: |
|
1130 from PyQt5.uic import compileUiDir |
1072 except ImportError: |
1131 except ImportError: |
1073 from PyQt5.uic import compileUi |
1132 if pyqtVariant == "PyQt4": |
|
1133 from PyQt4.uic import compileUi |
|
1134 else: |
|
1135 from PyQt5.uic import compileUi |
1074 |
1136 |
1075 def compileUiDir(dir, recurse=False, # __IGNORE_WARNING__ |
1137 def compileUiDir(dir, recurse=False, # __IGNORE_WARNING__ |
1076 map=None, **compileUi_args): |
1138 map=None, **compileUi_args): |
1077 """ |
1139 """ |
1078 Creates Python modules from Qt Designer .ui files in a directory or |
1140 Creates Python modules from Qt Designer .ui files in a directory or |