scripts/install.py

branch
eric7
changeset 9361
718bc86e1c3f
parent 9356
803a7a85b071
child 9366
57980203d6f8
equal deleted inserted replaced
9360:8b46571d9cc9 9361:718bc86e1c3f
42 doCompile = True 42 doCompile = True
43 yes2All = False 43 yes2All = False
44 withPyqt6Tools = False 44 withPyqt6Tools = False
45 verbose = False 45 verbose = False
46 cfg = {} 46 cfg = {}
47 progLanguages = ["Python", "Ruby", "QSS"] 47 progLanguages = ["MicroPython", "Python3", "QSS"]
48 sourceDir = "eric" 48 sourceDir = "eric"
49 eric7SourceDir = "" 49 eric7SourceDir = ""
50 configName = "eric7config.py" 50 configName = "eric7config.py"
51 defaultMacAppBundleName = "eric7.app" 51 defaultMacAppBundleName = "eric7.app"
52 defaultMacAppBundlePath = "/Applications" 52 defaultMacAppBundlePath = "/Applications"
589 # Cleanup API files 589 # Cleanup API files
590 with contextlib.suppress(AttributeError): 590 with contextlib.suppress(AttributeError):
591 apidir = getConfig("apidir") 591 apidir = getConfig("apidir")
592 for progLanguage in progLanguages: 592 for progLanguage in progLanguages:
593 for name in getConfig("apis"): 593 for name in getConfig("apis"):
594 # step 1: programming language as given
595 apiname = os.path.join(apidir, progLanguage, name)
596 if os.path.exists(apiname):
597 os.remove(apiname)
598 # step 2: programming language as lowercase
594 apiname = os.path.join(apidir, progLanguage.lower(), name) 599 apiname = os.path.join(apidir, progLanguage.lower(), name)
595 if os.path.exists(apiname): 600 if os.path.exists(apiname):
596 os.remove(apiname) 601 os.remove(apiname)
597 for apiname in glob.glob( 602 for apiname in glob.glob(
598 os.path.join(apidir, progLanguage.lower(), "*.bas") 603 os.path.join(apidir, progLanguage, "*.bas")
599 ): 604 ) + glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")):
600 if os.path.basename(apiname) != "eric7.bas": 605 os.remove(apiname)
601 os.remove(apiname) 606
607 # remove empty directories
608 with contextlib.suppress(FileNotFoundError, OSError):
609 os.rmdir(os.path.join(apidir, progLanguage))
610 with contextlib.suppress(FileNotFoundError, OSError):
611 os.rmdir(os.path.join(apidir, progLanguage.lower()))
602 612
603 if sys.platform == "darwin": 613 if sys.platform == "darwin":
604 # delete the Mac app bundle 614 # delete the Mac app bundle
605 cleanUpMacAppBundle() 615 cleanUpMacAppBundle()
606 except OSError as msg: 616 except OSError as msg:
909 ) 919 )
910 920
911 # install the API file 921 # install the API file
912 if installApis: 922 if installApis:
913 for progLanguage in progLanguages: 923 for progLanguage in progLanguages:
914 apidir = os.path.join(cfg["apidir"], progLanguage.lower()) 924 apidir = os.path.join(cfg["apidir"], progLanguage)
915 print("Installing {0} API files to '{1}'.".format(progLanguage, apidir)) 925 print("Installing {0} API files to '{1}'.".format(progLanguage, apidir))
916 try: 926 try:
917 if not os.path.exists(apidir): 927 if not os.path.exists(apidir):
918 os.makedirs(apidir) 928 os.makedirs(apidir)
919 except OSError: 929 except OSError:
931 ): 941 ):
932 try: 942 try:
933 shutilCopy(apiName, apidir) 943 shutilCopy(apiName, apidir)
934 except OSError: 944 except OSError:
935 print("Could not install '{0}' (no permission).".format(apiName)) 945 print("Could not install '{0}' (no permission).".format(apiName))
936 if progLanguage == "Python":
937 # copy Python3 API files to the same destination
938 for apiName in glob.glob(
939 os.path.join(eric7SourceDir, "APIs", "Python3", "*.api")
940 ):
941 try:
942 shutilCopy(apiName, apidir)
943 except OSError:
944 print(
945 "Could not install '{0}' (no permission).".format(apiName)
946 )
947 for apiName in glob.glob(
948 os.path.join(eric7SourceDir, "APIs", "Python3", "*.bas")
949 ):
950 if os.path.exists(
951 os.path.join(
952 apidir, os.path.basename(apiName.replace(".bas", ".api"))
953 )
954 ):
955 try:
956 shutilCopy(apiName, apidir)
957 except OSError:
958 print(
959 "Could not install '{0}' (no permission).".format(
960 apiName
961 )
962 )
963
964 # copy MicroPython API files to the same destination
965 for apiName in glob.glob(
966 os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.api")
967 ):
968 try:
969 shutilCopy(apiName, apidir)
970 except OSError:
971 print(
972 "Could not install '{0}' (no permission).".format(apiName)
973 )
974 for apiName in glob.glob(
975 os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.bas")
976 ):
977 if os.path.exists(
978 os.path.join(
979 apidir, os.path.basename(apiName.replace(".bas", ".api"))
980 )
981 ):
982 try:
983 shutilCopy(apiName, apidir)
984 except OSError:
985 print(
986 "Could not install '{0}' (no permission).".format(
987 apiName
988 )
989 )
990 946
991 # Create menu entry for Linux systems 947 # Create menu entry for Linux systems
992 if sys.platform.startswith("linux"): 948 if sys.platform.startswith("linux"):
993 createLinuxSpecifics() 949 createLinuxSpecifics()
994 950
1375 for progLanguage in progLanguages: 1331 for progLanguage in progLanguages:
1376 for apiName in sorted( 1332 for apiName in sorted(
1377 glob.glob(os.path.join(eric7SourceDir, "APIs", progLanguage, "*.api")) 1333 glob.glob(os.path.join(eric7SourceDir, "APIs", progLanguage, "*.api"))
1378 ): 1334 ):
1379 apis.append(os.path.basename(apiName)) 1335 apis.append(os.path.basename(apiName))
1380 if progLanguage == "Python":
1381 # treat Python3 API files the same as Python API files
1382 for apiName in sorted(
1383 glob.glob(os.path.join(eric7SourceDir, "APIs", "Python3", "*.api"))
1384 ):
1385 apis.append(os.path.basename(apiName))
1386
1387 # treat MicroPython API files the same as Python API files
1388 for apiName in sorted(
1389 glob.glob(
1390 os.path.join(eric7SourceDir, "APIs", "MicroPython", "*.api")
1391 )
1392 ):
1393 apis.append(os.path.basename(apiName))
1394 1336
1395 macConfig = ( 1337 macConfig = (
1396 ( 1338 (
1397 """ 'macAppBundlePath': r'{0}',\n""" 1339 """ 'macAppBundlePath': r'{0}',\n"""
1398 """ 'macAppBundleName': r'{1}',\n""" 1340 """ 'macAppBundleName': r'{1}',\n"""

eric ide

mercurial