diff -r f23c43e18046 -r 906485dcd210 scripts/install.py --- a/scripts/install.py Sun Oct 02 11:44:07 2022 +0200 +++ b/scripts/install.py Sat Oct 29 15:24:59 2022 +0200 @@ -23,8 +23,9 @@ import shlex import shutil import subprocess # secok +import sys +import sysconfig import time -import sys # Define the globals. progName = None @@ -32,7 +33,6 @@ modDir = None pyModDir = None platBinDir = None -platBinDirOld = None distDir = None apisDir = None installApis = True @@ -194,28 +194,16 @@ Module function to set the values of globals that need more than a simple assignment. """ - global platBinDir, modDir, pyModDir, apisDir, platBinDirOld - - import sysconfig + global platBinDir, modDir, pyModDir, apisDir if sys.platform.startswith(("win", "cygwin")): - platBinDir = sys.exec_prefix - if platBinDir.endswith("\\"): - platBinDir = platBinDir[:-1] - platBinDirOld = platBinDir - platBinDir = os.path.join(platBinDir, "Scripts") - if not os.path.exists(platBinDir): - platBinDir = platBinDirOld + platBinDir = sysconfig.get_path("scripts") else: - pyBinDir = os.path.normpath(os.path.dirname(sys.executable)) - if os.access(pyBinDir, os.W_OK): - # install the eric scripts along the python executable - platBinDir = pyBinDir - else: + # install the eric scripts along the python executable + platBinDir = sysconfig.get_path("scripts") + if not os.access(platBinDir, os.W_OK): # install them in the user's bin directory platBinDir = os.path.expanduser("~/bin") - if platBinDir != "/usr/local/bin" and os.access("/usr/local/bin", os.W_OK): - platBinDirOld = "/usr/local/bin" modDir = sysconfig.get_path("platlib") pyModDir = modDir @@ -491,7 +479,7 @@ """ Uninstall the old eric files. """ - global platBinDir, platBinDirOld + global platBinDir try: from eric7config import getConfig @@ -522,6 +510,7 @@ "eric7_editor", "eric7_hexeditor", "eric7_iconeditor", + "eric7_ide", "eric7_plugininstall", "eric7_pluginrepository", "eric7_pluginuninstall", @@ -535,15 +524,13 @@ "eric7_trpreviewer", "eric7_uipreviewer", "eric7_virtualenv", - "eric7", # obsolete scripts below "eric7_unittest", + "eric7", ] try: dirs = [platBinDir, getConfig("bindir")] - if platBinDirOld: - dirs.append(platBinDirOld) for rem_wname in rem_wnames: for d in dirs: for rwname in wrapperNames(d, rem_wname): @@ -602,7 +589,8 @@ for apiname in glob.glob( os.path.join(apidir, progLanguage, "*.bas") ) + glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")): - os.remove(apiname) + if os.path.exists(apiname): + os.remove(apiname) # remove empty directories with contextlib.suppress(FileNotFoundError, OSError): @@ -624,28 +612,32 @@ """ if os.getuid() == 0: for name in [ - "/usr/share/applications/eric7.desktop", "/usr/share/appdata/eric7.appdata.xml", "/usr/share/metainfo/eric7.appdata.xml", - "/usr/share/pixmaps/eric.png", + "/usr/share/applications/eric7_browser.desktop", + "/usr/share/applications/eric7_ide.desktop", "/usr/share/icons/eric.png", - "/usr/share/applications/eric7_browser.desktop", + "/usr/share/icons/ericWeb.png", + "/usr/share/pixmaps/eric.png", "/usr/share/pixmaps/ericWeb.png", - "/usr/share/icons/ericWeb.png", + # obsolete entries below + "/usr/share/applications/eric7.desktop", ]: if os.path.exists(name): os.remove(name) elif os.getuid() >= 1000: # it is assumed that user ids start at 1000 for name in [ - "~/.local/share/applications/eric7.desktop", "~/.local/share/appdata/eric7.appdata.xml", "~/.local/share/metainfo/eric7.appdata.xml", - "~/.local/share/pixmaps/eric.png", + "~/.local/share/applications/eric7_browser.desktop", + "~/.local/share/applications/eric7_ide.desktop", "~/.local/share/icons/eric.png", - "~/.local/share/applications/eric7_browser.desktop", + "~/.local/share/icons/ericWeb.png", + "~/.local/share/pixmaps/eric.png", "~/.local/share/pixmaps/ericWeb.png", - "~/.local/share/icons/ericWeb.png", + # obsolete entries below + "~/.local/share/applications/eric7.desktop", ]: path = os.path.expanduser(name) if os.path.exists(path): @@ -695,7 +687,7 @@ desktopEntry = getWinregEntry(regName, regPath) if desktopEntry: desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry)) - for linkName in windowsDesktopNames(): + for linkName in windowsDesktopNames(clean=True): linkPath = os.path.join(desktopFolder, linkName) if os.path.exists(linkPath): try: @@ -756,6 +748,7 @@ "eric7_editor", "eric7_hexeditor", "eric7_iconeditor", + "eric7_ide", "eric7_plugininstall", "eric7_pluginrepository", "eric7_pluginuninstall", @@ -769,7 +762,6 @@ "eric7_uipreviewer", "eric7_testing", "eric7_virtualenv", - "eric7", ]: wnames.append(createPyWrapper(cfg["ericDir"], name, scriptsDir)) @@ -894,7 +886,7 @@ return 7 # copy some text files to the doc area - for name in ["LICENSE.GPL3", "THANKS", "changelog"]: + for name in ["LICENSE.GPL3", "THANKS", "changelog.md", "ThirdParty.rst"]: try: shutilCopy(os.path.join(sourceDir, "docs", name), cfg["ericDocDir"]) except OSError: @@ -992,8 +984,8 @@ if not os.path.exists(dst): os.makedirs(dst) copyDesktopFile( - os.path.join(dataSourceDir, "eric7.desktop.in"), - os.path.join(dst, "eric7.desktop"), + os.path.join(dataSourceDir, "eric7_ide.desktop.in"), + os.path.join(dst, "eric7_ide.desktop"), ) copyDesktopFile( os.path.join(dataSourceDir, "eric7_browser.desktop.in"), @@ -1017,8 +1009,8 @@ "/usr/share/icons/hicolor/48x48/apps/eric.png", ) copyDesktopFile( - os.path.join(dataSourceDir, "eric7.desktop.in"), - "/usr/share/applications/eric7.desktop", + os.path.join(dataSourceDir, "eric7_ide.desktop.in"), + "/usr/share/applications/eric7_ide.desktop", ) if os.path.exists("/usr/share/metainfo"): copyAppStreamFile( @@ -1068,8 +1060,8 @@ os.path.join(localPath, "icons/hicolor/48x48/apps", "eric.png"), ) copyDesktopFile( - os.path.join(dataSourceDir, "eric7.desktop.in"), - os.path.join(localPath, "applications", "eric7.desktop"), + os.path.join(dataSourceDir, "eric7_ide.desktop.in"), + os.path.join(localPath, "applications", "eric7_ide.desktop"), ) copyAppStreamFile( os.path.join(dataSourceDir, "eric7.appdata.xml.in"), @@ -1178,7 +1170,7 @@ else: starter = "python{0}".format(sys.version_info.major) - wname = os.path.join(directories["exe"], "eric7") + wname = os.path.join(directories["exe"], "eric7_ide") # determine entry for DYLD_FRAMEWORK_PATH dyldLine = "" @@ -1209,9 +1201,7 @@ """\n""" """{0}""" """{1}""" - """exec "{2}" "{3}/{4}.py" "$@"\n""".format( - pathLine, dyldLine, starter, pydir, "eric7" - ) + """exec "{2}" "-m" "eric7" "$@"\n""".format(pathLine, dyldLine, starter) ) copyToFile(wname, wrapper) os.chmod(wname, 0o755) # secok @@ -1239,7 +1229,7 @@ """<plist version="1.0">\n""" """<dict>\n""" """ <key>CFBundleExecutable</key>\n""" - """ <string>eric7</string>\n""" + """ <string>eric7_ide</string>\n""" """ <key>CFBundleIconFile</key>\n""" """ <string>eric.icns</string>\n""" """ <key>CFBundleInfoDictionaryVersion</key>\n""" @@ -1935,9 +1925,9 @@ with contextlib.suppress(OSError): os.rename(fileName, fileName + ".orig") localHg = ( - os.path.join(sys.exec_prefix, "Scripts", "hg.exe") + os.path.join(sysconfig.get_path("scripts"), "hg.exe") if sys.platform.startswith(("win", "cygwin")) - else os.path.join(sys.exec_prefix, "bin", "hg") + else os.path.join(sysconfig.get_path("scripts"), "hg") ) for hg in (localHg, "hg"): with contextlib.suppress(OSError, subprocess.CalledProcessError): @@ -2010,20 +2000,24 @@ shortcut.save() -def windowsDesktopNames(): +def windowsDesktopNames(clean=False): """ Function to generate the link names for the Windows Desktop. + @param clean flag indicating to get the desktop names for a cleanup operation + @type bool @return list of desktop link names @rtype list of str """ - return [e[0] for e in windowsDesktopEntries()] + return [e[0] for e in windowsDesktopEntries(clean=clean)] -def windowsDesktopEntries(): +def windowsDesktopEntries(clean=False): """ Function to generate data for the Windows Desktop links. + @param clean flag indicating to get the desktop entries for a cleanup operation + @type bool @return list of tuples containing the desktop link name, the link target and the icon target @rtype list of tuples of (str, str, str) @@ -2033,8 +2027,8 @@ majorVersion, minorVersion = sys.version_info[:2] entriesTemplates = [ ( - "eric7 (Python {0}.{1}).lnk", - os.path.join(cfg["bindir"], "eric7.cmd"), + "eric7 IDE (Python {0}.{1}).lnk", + os.path.join(cfg["bindir"], "eric7_ide.cmd"), os.path.join(cfg["ericPixDir"], "eric7.ico"), ), ( @@ -2044,6 +2038,18 @@ ), ] + if clean: + # clean obsolete entries as well + entriesTemplates.extend( + [ + ( + "eric7 (Python {0}.{1}).lnk", + os.path.join(cfg["bindir"], "eric7_ide.cmd"), + os.path.join(cfg["ericPixDir"], "eric7.ico"), + ), + ] + ) + return [ (e[0].format(majorVersion, minorVersion), e[1], e[2]) for e in entriesTemplates ] @@ -2096,8 +2102,15 @@ optlist, args = getopt.getopt( argv[1:], "chvxza:b:d:f:", - ["clean-desktop", "help", "no-apis", "no-info", "verbose", "with-tools", - "yes"], + [ + "clean-desktop", + "help", + "no-apis", + "no-info", + "verbose", + "with-tools", + "yes", + ], ) elif sys.platform == "darwin": optlist, args = getopt.getopt(