--- a/scripts/install.py Sat Sep 07 14:45:27 2019 +0200 +++ b/scripts/install.py Sat Sep 07 16:10:29 2019 +0200 @@ -10,19 +10,6 @@ """ from __future__ import unicode_literals, print_function -try: - # Python2 only - import cStringIO as io - try: - from PyQt5 import sip - except ImportError: - import sip - sip.setapi('QString', 2) - sip.setapi('QVariant', 2) - sip.setapi('QTextStream', 2) - input = raw_input # __IGNORE_WARNING__ -except (ImportError): - import io # __IGNORE_WARNING__ import sys import os @@ -32,9 +19,9 @@ import glob import shutil import fnmatch -import codecs import subprocess import time +import io # Define the globals. progName = None @@ -50,7 +37,6 @@ doCleanDesktopLinks = False forceCleanDesktopLinks = False doCompile = True -includePythonVariant = False cfg = {} progLanguages = ["Python", "Ruby", "QSS"] sourceDir = "eric" @@ -63,50 +49,33 @@ macAppBundleName = defaultMacAppBundleName macAppBundlePath = defaultMacAppBundlePath macPythonExe = defaultMacPythonExe -pyqtVariant = "" -pyqtOverride = False # Define blacklisted versions of the prerequisites BlackLists = { "sip": [], - "PyQt4": [], "PyQt5": [], "QScintilla2": [], } PlatformsBlackLists = { "windows": { "sip": [], - "PyQt4": [], "PyQt5": [], "QScintilla2": [], }, "linux": { "sip": [], - "PyQt4": [], "PyQt5": [], "QScintilla2": [], }, "mac": { "sip": [], - "PyQt4": [], "PyQt5": [], "QScintilla2": [], }, } -# Define file name markers for Python variants -PythonMarkers = { - 2: "_py2", - 3: "_py3", -} -# Define a mapping of markers to full text -PythonTextMarkers = { - "_py2": "Python 2", - "_py3": "Python 3", -} - def exit(rcode=0): """ @@ -119,7 +88,6 @@ print() if sys.platform.startswith(("win", "cygwin")): - # different meaning of input between Py2 and Py3 try: input("Press enter to continue...") except (EOFError, SyntaxError): @@ -138,21 +106,20 @@ """ global progName, modDir, distDir, apisDir global macAppBundleName, macAppBundlePath, macPythonExe - global pyqtVariant print() print("Usage:") if sys.platform == "darwin": print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" - " [-m name] [-n path] [-p python] [--no-apis] [--pyqt=version]" + " [-m name] [-n path] [-p python] [--no-apis]" .format(progName)) elif sys.platform.startswith(("win", "cygwin")): print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]" - " [--clean-desktop] [--no-apis] [--pyqt=version]" + " [--clean-desktop] [--no-apis]" .format(progName)) else: print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" - " [--no-apis] [--pyqt=version]" + " [--no-apis]" .format(progName)) print("where:") print(" -h, --help display this help message") @@ -184,13 +151,7 @@ (" --clean-desktop delete desktop links before installation") print(" -x don't perform dependency checks (use on your own" " risk)") - print(" -y add the Python variant to the executable names") print(" -z don't compile the installed python files") - print(" --pyqt=version version of PyQt to be used (one of 4 or 5)") - if pyqtVariant: - print(" (default: {0})".format(pyqtVariant[-1])) - else: - print(" (no PyQt variant found)") print() print("The file given to the -f option must be valid Python code" " defining a") @@ -206,41 +167,12 @@ exit(rcode) -def determinePyQtVariant(): - """ - Module function to determine the PyQt variant to be used. - """ - global pyqtVariant, pyqtOverride - - pyqtVariant = "" - # need to handle the --pyqt= option here - if "--pyqt=4" in sys.argv: - pyqtVariant = "PyQt4" - pyqtOverride = True - elif "--pyqt=5" in sys.argv: - pyqtVariant = "PyQt5" - pyqtOverride = True - else: - try: - import PyQt5 # __IGNORE_WARNING__ - pyqtVariant = "PyQt5" - del sys.modules["PyQt5"] - except ImportError: - try: - import PyQt4 # __IGNORE_WARNING__ - pyqtVariant = "PyQt4" - del sys.modules["PyQt4"] - except ImportError: - # default to PyQt5, installation will be asked for - pyqtVariant = "PyQt5" - - def initGlobals(): """ Module function to set the values of globals that need more than a simple assignment. """ - global platBinDir, modDir, pyModDir, apisDir, pyqtVariant, platBinDirOld + global platBinDir, modDir, pyModDir, apisDir, platBinDirOld try: import distutils.sysconfig @@ -271,7 +203,7 @@ modDir = distutils.sysconfig.get_python_lib(True) pyModDir = modDir - pyqtDataDir = os.path.join(modDir, pyqtVariant) + pyqtDataDir = os.path.join(modDir, "PyQt5") if os.path.exists(os.path.join(pyqtDataDir, "qsci")): # it's the installer qtDataDir = pyqtDataDir @@ -281,10 +213,7 @@ else: # determine dynamically try: - if pyqtVariant == "PyQt4": - from PyQt4.QtCore import QLibraryInfo - else: - from PyQt5.QtCore import QLibraryInfo + from PyQt5.QtCore import QLibraryInfo qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath) except ImportError: qtDataDir = None @@ -302,53 +231,39 @@ @param text the contents to copy to the file. """ f = open(name, "w") - if sys.version_info[0] == 2: - text = codecs.encode(text, "utf-8") f.write(text) f.close() -def copyDesktopFile(src, dst, marker): +def copyDesktopFile(src, dst): """ Modify a desktop file and write it to its destination. @param src source file name (string) @param dst destination file name (string) - @param marker marker to be used (string) """ global cfg, platBinDir - if sys.version_info[0] == 2: - f = codecs.open(src, "r", "utf-8") - else: - f = open(src, "r", encoding="utf-8") + f = open(src, "r", encoding="utf-8") text = f.read() f.close() text = text.replace("@BINDIR@", platBinDir) - text = text.replace("@MARKER@", marker) - if marker: - t_marker = " ({0})".format(PythonTextMarkers[marker]) - else: - t_marker = "" - text = text.replace("@PY_MARKER@", t_marker) + text = text.replace("@MARKER@", "") + text = text.replace("@PY_MARKER@", "") - if sys.version_info[0] == 2: - f = codecs.open(dst, "w", "utf-8") - else: - f = open(dst, "w", encoding="utf-8") + f = open(dst, "w", encoding="utf-8") f.write(text) f.close() os.chmod(dst, 0o644) -def copyAppStreamFile(src, dst, marker): +def copyAppStreamFile(src, dst): """ Modify an appstream file and write it to its destination. @param src source file name (string) @param dst destination file name (string) - @param marker marker to be used (string) """ if os.path.exists(os.path.join("eric", "eric6", "UI", "Info.py")): # Installing from archive @@ -359,21 +274,15 @@ else: Version = "Unknown" - if sys.version_info[0] == 2: - f = codecs.open(src, "r", "utf-8") - else: - f = open(src, "r", encoding="utf-8") + f = open(src, "r", encoding="utf-8") text = f.read() f.close() - text = text.replace("@MARKER@", marker)\ + text = text.replace("@MARKER@", "")\ .replace("@VERSION@", Version.split(None, 1)[0])\ .replace("@DATE@", time.strftime("%Y-%m-%d")) - if sys.version_info[0] == 2: - f = codecs.open(dst, "w", "utf-8") - else: - f = open(dst, "w", encoding="utf-8") + f = open(dst, "w", encoding="utf-8") f.write(text) f.close() os.chmod(dst, 0o644) @@ -408,33 +317,21 @@ application (boolean) @return the platform specific name of the wrapper (string) """ - global includePythonVariant, pyqtVariant, pyqtOverride - - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - else: - marker = "" - - if pyqtOverride and pyqtVariant == "PyQt4": - pyqt4opt = " --pyqt4" - else: - pyqt4opt = "" - # all kinds of Windows systems if sys.platform.startswith(("win", "cygwin")): - wname = wfile + marker + ".cmd" + wname = wfile + ".cmd" if isGuiScript: wrapper = \ '''@echo off\n''' \ '''start "" "{2}\\pythonw.exe"''' \ - ''' "{0}\\{1}.pyw"{3}''' \ + ''' "{0}\\{1}.pyw"''' \ ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( - pydir, wfile, sys.exec_prefix, pyqt4opt) + pydir, wfile, sys.exec_prefix) else: wrapper = \ - '''@"{0}\\python" "{1}\\{2}.py"{3}''' \ + '''@"{0}\\python" "{1}\\{2}.py"''' \ ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( - sys.exec_prefix, pydir, wfile, pyqt4opt) + sys.exec_prefix, pydir, wfile) # Mac OS X elif sys.platform == "darwin": @@ -442,19 +339,19 @@ pyexec = "{0}/bin/pythonw{1}".format(sys.exec_prefix, major) if not os.path.exists(pyexec): pyexec = "{0}/bin/python{1}".format(sys.exec_prefix, major) - wname = wfile + marker + wname = wfile wrapper = ('''#!/bin/sh\n''' '''\n''' - '''exec "{0}" "{1}/{2}.py"{3} "$@"\n''' - .format(pyexec, pydir, wfile, pyqt4opt)) + '''exec "{0}" "{1}/{2}.py" "$@"\n''' + .format(pyexec, pydir, wfile)) # *nix systems else: - wname = wfile + marker + wname = wfile wrapper = ('''#!/bin/sh\n''' '''\n''' - '''exec "{0}" "{1}/{2}.py"{3} "$@"\n''' - .format(sys.executable, pydir, wfile, pyqt4opt)) + '''exec "{0}" "{1}/{2}.py" "$@"\n''' + .format(sys.executable, pydir, wfile)) wname = os.path.join(saveDir, wname) copyToFile(wname, wrapper) @@ -574,7 +471,7 @@ """ Uninstall the old eric files. """ - global platBinDir, platBinDirOld, includePythonVariant + global platBinDir, platBinDirOld try: from eric6config import getConfig @@ -605,13 +502,11 @@ "eric6_tray", "eric6_editor", "eric6_plugininstall", "eric6_pluginuninstall", "eric6_pluginrepository", "eric6_sqlbrowser", - "eric6_webbrowser", "eric6_iconeditor", - "eric6_snap", "eric6_hexeditor", "eric6_browser", - "eric6_shell", + "eric6_iconeditor", "eric6_snap", "eric6_hexeditor", + "eric6_browser", "eric6_shell", + # from Python2 era + "eric6_webbrowser", ] - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - rem_wnames = [n + marker for n in rem_wnames] try: dirs = [platBinDir, getConfig('bindir')] @@ -680,20 +575,15 @@ "/usr/share/pixmaps/ericWeb.png"]: if os.path.exists(name): os.remove(name) - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - else: - marker = "" for name in [ - "/usr/share/applications/eric6" + marker + ".desktop", - "/usr/share/appdata/eric6" + marker + ".appdata.xml", - "/usr/share/metainfo/eric6" + marker + ".appdata.xml", - "/usr/share/applications/eric6_webbrowser" + marker + - ".desktop", - "/usr/share/applications/eric6_browser" + marker + - ".desktop", - "/usr/share/pixmaps/eric" + marker + ".png", - "/usr/share/pixmaps/ericWeb" + marker + ".png", + "/usr/share/applications/eric6.desktop", + "/usr/share/appdata/eric6.appdata.xml", + "/usr/share/metainfo/eric6.appdata.xml", + "/usr/share/applications/eric6_browser.desktop", + "/usr/share/pixmaps/eric.png", + "/usr/share/pixmaps/ericWeb.png", + # from Python2 era + "/usr/share/applications/eric6_webbrowser.desktop", ]: if os.path.exists(name): os.remove(name) @@ -704,20 +594,15 @@ path = os.path.expanduser(name) if os.path.exists(path): os.remove(path) - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - else: - marker = "" for name in [ - "~/.local/share/applications/eric6" + marker + ".desktop", - "~/.local/share/appdata/eric6" + marker + ".appdata.xml", - "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", - "~/.local/share/applications/eric6_webbrowser" + marker + - ".desktop", - "~/.local/share/applications/eric6_browser" + marker + - ".desktop", - "~/.local/share/pixmaps/eric" + marker + ".png", - "~/.local/share/pixmaps/ericWeb" + marker + ".png", + "~/.local/share/applications/eric6.desktop", + "~/.local/share/appdata/eric6.appdata.xml", + "~/.local/share/metainfo/eric6.appdata.xml", + "~/.local/share/applications/eric6_browser.desktop", + "~/.local/share/pixmaps/eric.png", + "~/.local/share/pixmaps/ericWeb.png", + # from Python2 era + "/usr/share/applications/eric6_webbrowser.desktop", ]: path = os.path.expanduser(name) if os.path.exists(path): @@ -809,7 +694,7 @@ @return result code (integer) """ global distDir, doCleanup, cfg, progLanguages, sourceDir, configName - global includePythonVariant, installApis + global installApis # Create the platform specific wrappers. scriptsDir = "install_scripts" @@ -824,8 +709,8 @@ "eric6_pluginuninstall", "eric6_qregexp", "eric6_qregularexpression", "eric6_re", "eric6_snap", "eric6_sqlbrowser", "eric6_tray", "eric6_trpreviewer", - "eric6_uipreviewer", "eric6_unittest", "eric6_webbrowser", - "eric6_browser", "eric6_shell", "eric6"]: + "eric6_uipreviewer", "eric6_unittest", "eric6_browser", + "eric6_shell", "eric6"]: wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir)) # set install prefix, if not None @@ -1016,77 +901,55 @@ """ Install Linux specific files. """ - global distDir, sourceDir, includePythonVariant + global distDir, sourceDir - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - else: - marker = "" - if distDir: dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) if not os.path.exists(dst): os.makedirs(dst) shutilCopy( os.path.join(eric6SourceDir, "icons", "default", "eric.png"), - os.path.join(dst, "eric" + marker + ".png")) + os.path.join(dst, "eric.png")) shutilCopy( os.path.join(eric6SourceDir, "icons", "default", "ericWeb48.png"), - os.path.join(dst, "ericWeb" + marker + ".png")) + os.path.join(dst, "ericWeb.png")) dst = os.path.normpath( os.path.join(distDir, "usr/share/applications")) if not os.path.exists(dst): os.makedirs(dst) copyDesktopFile(os.path.join(sourceDir, "linux", "eric6.desktop.in"), - os.path.join(dst, "eric6" + marker + ".desktop"), - marker) - copyDesktopFile( - os.path.join(sourceDir, "linux", "eric6_webbrowser.desktop.in"), - os.path.join(dst, "eric6_webbrowser" + marker + ".desktop"), - marker) + os.path.join(dst, "eric6.desktop")) copyDesktopFile( os.path.join(sourceDir, "linux", "eric6_browser.desktop.in"), - os.path.join(dst, "eric6_browser" + marker + ".desktop"), - marker) + os.path.join(dst, "eric6_browser.desktop")) dst = os.path.normpath( os.path.join(distDir, "usr/share/metainfo")) if not os.path.exists(dst): os.makedirs(dst) copyAppStreamFile( os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), - os.path.join(dst, "eric6" + marker + ".appdata.xml"), - marker) + os.path.join(dst, "eric6.appdata.xml")) elif os.getuid() == 0: shutilCopy(os.path.join( eric6SourceDir, "icons", "default", "eric.png"), - "/usr/share/pixmaps/eric" + marker + ".png") + "/usr/share/pixmaps/eric.png") copyDesktopFile( os.path.join(sourceDir, "linux", "eric6.desktop.in"), - "/usr/share/applications/eric6" + marker + ".desktop", - marker) + "/usr/share/applications/eric6.desktop") if os.path.exists("/usr/share/metainfo"): copyAppStreamFile( os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), - "/usr/share/metainfo/eric6" + marker + ".appdata.xml", - marker) + "/usr/share/metainfo/eric6.appdata.xml") elif os.path.exists("/usr/share/appdata"): copyAppStreamFile( os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), - "/usr/share/appdata/eric6" + marker + ".appdata.xml", - marker) + "/usr/share/appdata/eric6.appdata.xml") shutilCopy(os.path.join( eric6SourceDir, "icons", "default", "ericWeb48.png"), - "/usr/share/pixmaps/ericWeb" + marker + ".png") - copyDesktopFile( - os.path.join(sourceDir, "linux", "eric6_webbrowser.desktop.in"), - "/usr/share/applications/eric6_webbrowser" + marker + - ".desktop", - marker) + "/usr/share/pixmaps/ericWeb.png") copyDesktopFile( os.path.join(sourceDir, "linux", "eric6_browser.desktop.in"), - "/usr/share/applications/eric6_browser" + marker + - ".desktop", - marker) + "/usr/share/applications/eric6_browser.desktop") elif os.getuid() >= 1000: # it is assumed, that user ids start at 1000 localPath = os.path.join(os.path.expanduser("~"), @@ -1100,36 +963,22 @@ # now copy the files shutilCopy( os.path.join(eric6SourceDir, "icons", "default", "eric.png"), - os.path.join(localPath, "pixmaps", "eric" + marker + ".png")) + os.path.join(localPath, "pixmaps", "eric.png")) copyDesktopFile( os.path.join(sourceDir, "linux", "eric6.desktop.in"), - os.path.join(localPath, "applications", - "eric6" + marker + ".desktop"), - marker) - copyAppStreamFile( - os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), - os.path.join(localPath, "metainfo", - "eric6" + marker + ".appdata.xml"), - marker) + os.path.join(localPath, "applications", "eric6.desktop")) copyAppStreamFile( os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), - os.path.join(localPath, "appdata", - "eric6" + marker + ".appdata.xml"), - marker) + os.path.join(localPath, "metainfo", "eric6.appdata.xml")) + copyAppStreamFile( + os.path.join(sourceDir, "linux", "eric6.appdata.xml.in"), + os.path.join(localPath, "appdata", "eric6.appdata.xml")) shutilCopy( os.path.join(eric6SourceDir, "icons", "default", "ericWeb48.png"), - os.path.join(localPath, "pixmaps", - "ericWeb" + marker + ".png")) - copyDesktopFile( - os.path.join(sourceDir, "linux", "eric6_webbrowser.desktop.in"), - os.path.join(localPath, "applications", - "eric6_webbrowser" + marker + ".desktop"), - marker) + os.path.join(localPath, "pixmaps", "ericWeb.png")) copyDesktopFile( os.path.join(sourceDir, "linux", "eric6_browser.desktop.in"), - os.path.join(localPath, "applications", - "eric6_browser" + marker + ".desktop"), - marker) + os.path.join(localPath, "applications", "eric6_browser.desktop")) def createWindowsLinks(): @@ -1152,8 +1001,6 @@ os.path.join(os.path.dirname(__file__), "create_windows_links.py"), ] - if includePythonVariant: - args.append("-y") subprocess.call(args) else: print( @@ -1199,7 +1046,7 @@ eventually be installed @type str """ - global cfg, macAppBundleName, macPythonExe, macAppBundlePath, pyqtVariant + global cfg, macAppBundleName, macPythonExe, macAppBundlePath directories = { "contents": "{0}/{1}/Contents/".format( @@ -1224,10 +1071,7 @@ # determine entry for DYLD_FRAMEWORK_PATH dyldLine = "" try: - if pyqtVariant == "PyQt4": - from PyQt4.QtCore import QLibraryInfo - else: - from PyQt5.QtCore import QLibraryInfo + from PyQt5.QtCore import QLibraryInfo qtLibraryDir = QLibraryInfo.location(QLibraryInfo.LibrariesPath) except ImportError: qtLibraryDir = "" @@ -1437,10 +1281,7 @@ ok = False print("{0}\n\nShall '{1}' be installed using pip? (Y/n)" .format(message, packageName), end=" ") - if sys.version_info[0] == 2: - answer = raw_input() # __IGNORE_WARNING__ - else: - answer = input() + answer = input() if answer in ("", "Y", "y"): exitCode = subprocess.call( [sys.executable, "-m", "pip", "install", packageName]) @@ -1457,15 +1298,11 @@ # perform dependency checks print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) - if sys.version_info < (2, 7, 10): - print('Sorry, you must have Python 2.7.10 or higher or ' - 'Python 3.5.0 or higher.') - exit(5) - elif sys.version_info < (3, 5, 0) and sys.version_info[0] == 3: + if sys.version_info < (3, 5, 0): print('Sorry, you must have Python 3.5.0 or higher.') exit(5) if sys.version_info[0] > 3: - print('Sorry, eric6 requires Python 3 or Python 2 for running.') + print('Sorry, eric6 requires Python 3 for running.') exit(5) try: @@ -1475,121 +1312,89 @@ print('Please install it and try again.') exit(5) - if pyqtVariant == "PyQt4": - try: - from PyQt4.QtCore import qVersion - except ImportError as msg: - print('Sorry, please install PyQt4.') - print('Error: {0}'.format(msg)) - exit(1) - print("Found PyQt4") - else: - try: - from PyQt5.QtCore import qVersion - except ImportError as msg: - if sys.version_info[0] == 2: - # no PyQt5 wheels available for Python 2 - installed = False - else: - installed = pipInstall( - "PyQt5", - "PyQt5 could not be detected.\nError: {0}".format(msg) - ) - if installed: - # try to import it again - try: - from PyQt5.QtCore import qVersion - except ImportError as msg: - print('Sorry, please install PyQt5.') - print('Error: {0}'.format(msg)) - exit(1) - else: + try: + from PyQt5.QtCore import qVersion + except ImportError as msg: + installed = pipInstall( + "PyQt5", + "PyQt5 could not be detected.\nError: {0}".format(msg) + ) + if installed: + # try to import it again + try: + from PyQt5.QtCore import qVersion + except ImportError as msg: print('Sorry, please install PyQt5.') print('Error: {0}'.format(msg)) exit(1) - print("Found PyQt5") + else: + print('Sorry, please install PyQt5.') + print('Error: {0}'.format(msg)) + exit(1) + print("Found PyQt5") try: - if pyqtVariant == "PyQt4": - pyuic = "pyuic4" - from PyQt4 import uic # __IGNORE_WARNING__ - else: - pyuic = "pyuic5" - from PyQt5 import uic # __IGNORE_WARNING__ + pyuic = "pyuic5" + from PyQt5 import uic # __IGNORE_WARNING__ except ImportError as msg: print("Sorry, {0} is not installed.".format(pyuic)) print('Error: {0}'.format(msg)) exit(1) print("Found {0}".format(pyuic)) - if pyqtVariant != "PyQt4": - try: - from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__ - except ImportError as msg: - from PyQt5.QtCore import PYQT_VERSION - if PYQT_VERSION >= 0x50c00: - # PyQt 5.12 separated QtWebEngine into a separate wheel - installed = pipInstall( - "PyQtWebEngine", - "PyQtWebEngine could not be detected.\nError: {0}" - .format(msg) - ) - - try: - from PyQt5 import QtChart # __IGNORE_WARNING__ - except ImportError as msg: + try: + from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__ + except ImportError as msg: + from PyQt5.QtCore import PYQT_VERSION + if PYQT_VERSION >= 0x050c00: + # PyQt 5.12 separated QtWebEngine into a separate wheel installed = pipInstall( - "PyQtChart", - "PyQtChart could not be detected.\nError: {0}" + "PyQtWebEngine", + "PyQtWebEngine could not be detected.\nError: {0}" .format(msg) ) try: - if pyqtVariant == "PyQt4": - from PyQt4 import Qsci # __IGNORE_WARNING__ - else: - from PyQt5 import Qsci # __IGNORE_WARNING__ + from PyQt5 import QtChart # __IGNORE_WARNING__ + except ImportError as msg: + installed = pipInstall( + "PyQtChart", + "PyQtChart could not be detected.\nError: {0}" + .format(msg) + ) + + try: + from PyQt5 import Qsci # __IGNORE_WARNING__ except ImportError as msg: - if pyqtVariant == "PyQt4": - message = str(msg) + installed = pipInstall( + "QScintilla", + "QScintilla could not be detected.\nError: {0}".format(msg) + ) + if installed: + # try to import it again + try: + from PyQt5 import Qsci # __IGNORE_WARNING__ + message = None + except ImportError as msg: + message = str(msg) else: - installed = pipInstall( - "QScintilla", - "QScintilla could not be detected.\nError: {0}".format(msg) - ) - if installed: - # try to import it again - try: - from PyQt5 import Qsci # __IGNORE_WARNING__ - message = None - except ImportError as msg: - message = str(msg) - else: - message = "QScintilla could not be installed." + message = "QScintilla could not be installed." if message: print("Sorry, please install QScintilla2 and") - print("its PyQt5/PyQt4 wrapper.") + print("its PyQt5 wrapper.") print('Error: {0}'.format(message)) exit(1) print("Found QScintilla2") - if pyqtVariant == "PyQt4": - impModulesList = [ - "PyQt4.QtGui", "PyQt4.QtNetwork", "PyQt4.QtSql", - "PyQt4.QtSvg", "PyQt4.QtWebKit", - ] - altModulesList = [] - else: - impModulesList = [ - "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport", - "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWidgets", - ] - altModulesList = [ - # Tuple with alternatives, flag indicating it's ok to not be - # available (e.g. for 32-Bit Windows) - (("PyQt5.QtWebEngineWidgets", "PyQt5.QtWebKitWidgets"), - sys.maxsize <= 2**32), - ] + impModulesList = [ + "PyQt5.QtGui", "PyQt5.QtNetwork", "PyQt5.QtPrintSupport", + "PyQt5.QtSql", "PyQt5.QtSvg", "PyQt5.QtWidgets", + ] + altModulesList = [ + # Tuple with alternatives, flag indicating it's ok to not be + # available (e.g. for 32-Bit Windows) + (("PyQt5.QtWebEngineWidgets", ), sys.maxsize <= 2**32), + ] # check mandatory modules modulesOK = True for impModule in impModulesList: @@ -1636,11 +1441,8 @@ qtMajor = int(qVersion().split('.')[0]) qtMinor = int(qVersion().split('.')[1]) print("Qt Version: {0}".format(qVersion().strip())) - if qtMajor < 4 or \ - (qtMajor == 4 and qtMinor < 8) or \ - (qtMajor == 5 and qtMinor < 9): - print('Sorry, you must have Qt version 4.8.0 or better or') - print('5.9.0 or better.') + if qtMajor == 5 and qtMinor < 9: + print('Sorry, you must have Qt version 5.9.0 or better.') exit(2) # check version of sip @@ -1676,10 +1478,7 @@ pass # check version of PyQt - if pyqtVariant == "PyQt4": - from PyQt4.QtCore import PYQT_VERSION_STR - else: - from PyQt5.QtCore import PYQT_VERSION_STR + from PyQt5.QtCore import PYQT_VERSION_STR pyqtVersion = PYQT_VERSION_STR print("PyQt Version:", pyqtVersion.strip()) # always assume, that snapshots or dev versions are new enough @@ -1690,15 +1489,12 @@ major = int(major) minor = int(minor) pat = int(pat) - if major < 4 or \ - (major == 4 and minor < 10) or \ - (major == 5 and minor < 9): - print('Sorry, you must have PyQt 4.10.0 or better or') - print('PyQt 5.9.0 or better or' + if major == 5 and minor < 9: + print('Sorry, you must have PyQt 5.9.0 or better or' ' a recent snapshot release.') exit(4) # check for blacklisted versions - for vers in BlackLists[pyqtVariant] + PlatformBlackLists[pyqtVariant]: + for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]: if vers == pyqtVersion: print('Sorry, PyQt version {0} is not compatible with eric6.' .format(vers)) @@ -1706,10 +1502,7 @@ exit(4) # check version of QScintilla - if pyqtVariant == "PyQt4": - from PyQt4.Qsci import QSCINTILLA_VERSION_STR - else: - from PyQt5.Qsci import QSCINTILLA_VERSION_STR + from PyQt5.Qsci import QSCINTILLA_VERSION_STR scintillaVersion = QSCINTILLA_VERSION_STR print("QScintilla Version:", QSCINTILLA_VERSION_STR.strip()) # always assume, that snapshots or dev versions are new enough @@ -1754,10 +1547,7 @@ """ Compile the .ui files to Python sources. """ - if pyqtVariant == "PyQt4": - from PyQt4.uic import compileUiDir - else: - from PyQt5.uic import compileUiDir + from PyQt5.uic import compileUiDir compileUiDir(eric6SourceDir, True, __pyName) @@ -1776,18 +1566,14 @@ pass try: hgOut = subprocess.check_output(["hg", "identify", "-i"]) - if sys.version_info[0] == 3: - hgOut = hgOut.decode() + hgOut = hgOut.decode() except (OSError, subprocess.CalledProcessError): hgOut = "" if hgOut: hgOut = hgOut.strip() if hgOut.endswith("+"): hgOut = hgOut[:-1] - if sys.version_info[0] == 2: - f = codecs.open(fileName + ".orig", "r", "utf-8") - else: - f = open(fileName + ".orig", "r", encoding="utf-8") + f = open(fileName + ".orig", "r", encoding="utf-8") text = f.read() f.close() text = text.replace("@@REVISION@@", hgOut)\ @@ -1809,12 +1595,9 @@ @rtype any """ try: - import _winreg as winreg + import winreg except ImportError: - try: - import winreg - except ImportError: - return None + return None try: registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, @@ -1870,31 +1653,17 @@ the link target and the icon target @rtype list of tuples of (str, str, str) """ - global cfg, includePythonVariant - - if includePythonVariant: - marker = PythonMarkers[sys.version_info.major] - else: - marker = "" + global cfg majorVersion, minorVersion = sys.version_info[:2] entriesTemplates = [ ("eric6 (Python {0}.{1}).lnk", - os.path.join(cfg["bindir"], "eric6" + marker + ".cmd"), + os.path.join(cfg["bindir"], "eric6.cmd"), os.path.join(cfg["ericPixDir"], "eric6.ico")), + ("eric6 Browser (Python {0}.{1}).lnk", + os.path.join(cfg["bindir"], "eric6_browse.cmd"), + os.path.join(cfg["ericPixDir"], "ericWeb48.ico")), ] - if sys.version_info.major == 2: - entriesTemplates.append(( - "eric6 Browser (Python {0}.{1}).lnk", - os.path.join(cfg["bindir"], "eric6_webbrowser" + marker + ".cmd"), - os.path.join(cfg["ericPixDir"], "ericWeb48.ico") - )) - else: - entriesTemplates.append(( - "eric6 Browser (Python {0}.{1}).lnk", - os.path.join(cfg["bindir"], "eric6_browser" + marker + ".cmd"), - os.path.join(cfg["ericPixDir"], "ericWeb48.ico") - )) return [ (e[0].format(majorVersion, minorVersion), e[1], e[2]) @@ -1924,13 +1693,12 @@ # Parse the command line. global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir - global sourceDir, eric6SourceDir, configName, includePythonVariant + global sourceDir, eric6SourceDir, configName global macAppBundlePath, macAppBundleName, macPythonExe - global pyqtVariant, pyqtOverride, installApis, doCleanDesktopLinks + global installApis, doCleanDesktopLinks - if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9): - print('Sorry, eric6 requires at least Python 2.7 or ' - 'Python 3 for running.') + if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99): + print('Sorry, eric6 requires at least Python 3.5 for running.') exit(5) progName = os.path.basename(argv[0]) @@ -1938,22 +1706,21 @@ if os.path.dirname(argv[0]): os.chdir(os.path.dirname(argv[0])) - determinePyQtVariant() initGlobals() try: if sys.platform.startswith(("win", "cygwin")): optlist, args = getopt.getopt( - argv[1:], "chxyza:b:d:f:", - ["help", "pyqt=", "no-apis"]) + argv[1:], "chxza:b:d:f:", + ["help", "no-apis"]) elif sys.platform == "darwin": optlist, args = getopt.getopt( - argv[1:], "chxyza:b:d:f:i:m:n:p:", - ["help", "pyqt=", "no-apis"]) + argv[1:], "chxza:b:d:f:i:m:n:p:", + ["help", "no-apis"]) else: optlist, args = getopt.getopt( - argv[1:], "chxyza:b:d:f:i:", - ["help", "pyqt=", "no-apis"]) + argv[1:], "chxza:b:d:f:i:", + ["help", "no-apis"]) except getopt.GetoptError as err: print(err) usage() @@ -1979,8 +1746,6 @@ doCleanup = False elif opt == "-z": doCompile = False - elif opt == "-y": - includePythonVariant = True elif opt == "-f": try: exec(compile(open(arg).read(), arg, 'exec'), globals()) @@ -1996,12 +1761,6 @@ macAppBundlePath = arg elif opt == "-p": macPythonExe = arg - elif opt == "--pyqt": - if arg not in ["4", "5"]: - print("Invalid PyQt version given; should be 4 or 5. Aborting") - exit(6) - pyqtVariant = "PyQt{0}".format(arg) - pyqtOverride = True elif opt == "--no-apis": installApis = False elif opt == "--clean-desktop": @@ -2072,7 +1831,6 @@ if doCompile: print("\nCompiling source files ...") - # Hide compile errors (mainly because of Py2/Py3 differences) skipRe = re.compile(r"DebugClients[\\/]Python[\\/]") sys.stdout = io.StringIO() if distDir: