diff -r 8b46571d9cc9 -r 718bc86e1c3f scripts/install.py --- a/scripts/install.py Tue Sep 27 14:58:59 2022 +0200 +++ b/scripts/install.py Tue Sep 27 14:59:32 2022 +0200 @@ -44,7 +44,7 @@ withPyqt6Tools = False verbose = False cfg = {} -progLanguages = ["Python", "Ruby", "QSS"] +progLanguages = ["MicroPython", "Python3", "QSS"] sourceDir = "eric" eric7SourceDir = "" configName = "eric7config.py" @@ -591,14 +591,24 @@ apidir = getConfig("apidir") for progLanguage in progLanguages: for name in getConfig("apis"): + # step 1: programming language as given + apiname = os.path.join(apidir, progLanguage, name) + if os.path.exists(apiname): + os.remove(apiname) + # step 2: programming language as lowercase apiname = os.path.join(apidir, progLanguage.lower(), name) if os.path.exists(apiname): os.remove(apiname) for apiname in glob.glob( - os.path.join(apidir, progLanguage.lower(), "*.bas") - ): - if os.path.basename(apiname) != "eric7.bas": - os.remove(apiname) + os.path.join(apidir, progLanguage, "*.bas") + ) + glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")): + os.remove(apiname) + + # remove empty directories + with contextlib.suppress(FileNotFoundError, OSError): + os.rmdir(os.path.join(apidir, progLanguage)) + with contextlib.suppress(FileNotFoundError, OSError): + os.rmdir(os.path.join(apidir, progLanguage.lower())) if sys.platform == "darwin": # delete the Mac app bundle @@ -911,7 +921,7 @@ # install the API file if installApis: for progLanguage in progLanguages: - apidir = os.path.join(cfg["apidir"], progLanguage.lower()) + apidir = os.path.join(cfg["apidir"], progLanguage) print("Installing {0} API files to '{1}'.".format(progLanguage, apidir)) try: if not os.path.exists(apidir): @@ -933,60 +943,6 @@ shutilCopy(apiName, apidir) except OSError: print("Could not install '{0}' (no permission).".format(apiName)) - if progLanguage == "Python": - # copy Python3 API files to the same destination - for apiName in glob.glob( - os.path.join(eric7SourceDir, "APIs", "Python3", "*.api") - ): - try: - shutilCopy(apiName, apidir) - except OSError: - print( - "Could not install '{0}' (no permission).".format(apiName) - ) - for apiName in glob.glob( - os.path.join(eric7SourceDir, "APIs", "Python3", "*.bas") - ): - if os.path.exists( - os.path.join( - apidir, os.path.basename(apiName.replace(".bas", ".api")) - ) - ): - try: - shutilCopy(apiName, apidir) - except OSError: - print( - "Could not install '{0}' (no permission).".format( - apiName - ) - ) - - # copy MicroPython API files to the same destination - for apiName in glob.glob( - os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.api") - ): - try: - shutilCopy(apiName, apidir) - except OSError: - print( - "Could not install '{0}' (no permission).".format(apiName) - ) - for apiName in glob.glob( - os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.bas") - ): - if os.path.exists( - os.path.join( - apidir, os.path.basename(apiName.replace(".bas", ".api")) - ) - ): - try: - shutilCopy(apiName, apidir) - except OSError: - print( - "Could not install '{0}' (no permission).".format( - apiName - ) - ) # Create menu entry for Linux systems if sys.platform.startswith("linux"): @@ -1377,20 +1333,6 @@ glob.glob(os.path.join(eric7SourceDir, "APIs", progLanguage, "*.api")) ): apis.append(os.path.basename(apiName)) - if progLanguage == "Python": - # treat Python3 API files the same as Python API files - for apiName in sorted( - glob.glob(os.path.join(eric7SourceDir, "APIs", "Python3", "*.api")) - ): - apis.append(os.path.basename(apiName)) - - # treat MicroPython API files the same as Python API files - for apiName in sorted( - glob.glob( - os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.api") - ) - ): - apis.append(os.path.basename(apiName)) macConfig = ( (