scripts/install.py

branch
eric7-maintenance
changeset 10534
783d835d7fe4
parent 10460
3b34efa2857c
parent 10525
e2b37b8ae403
child 10616
4aa36fcd4a30
equal deleted inserted replaced
10461:5fbbda78c175 10534:783d835d7fe4
15 import datetime 15 import datetime
16 import fnmatch 16 import fnmatch
17 import getpass 17 import getpass
18 import glob 18 import glob
19 import importlib 19 import importlib
20 import importlib.util
20 import io 21 import io
21 import json 22 import json
22 import os 23 import os
23 import py_compile 24 import py_compile
24 import re 25 import re
66 createInstallInfoFile = True 67 createInstallInfoFile = True
67 installInfoName = "eric7install.json" 68 installInfoName = "eric7install.json"
68 installInfo = {} 69 installInfo = {}
69 installCwd = "" 70 installCwd = ""
70 71
71 # Define blacklisted versions of the prerequisites 72 # Define blocklisted versions of the prerequisites
72 BlackLists = { 73 BlockLists = {
73 "sip": [], 74 "sip": [],
74 "PyQt6": [], 75 "PyQt6": [],
75 "QScintilla2": [], 76 "QScintilla2": [],
76 } 77 }
77 PlatformsBlackLists = { 78 PlatformsBlockLists = {
78 "freebsd": { 79 "freebsd": {
79 "sip": [], 80 "sip": [],
80 "PyQt6": [], 81 "PyQt6": [],
81 "QScintilla2": [], 82 "QScintilla2": [],
82 }, 83 },
472 "eric7_doc", 473 "eric7_doc",
473 "eric7_editor", 474 "eric7_editor",
474 "eric7_hexeditor", 475 "eric7_hexeditor",
475 "eric7_iconeditor", 476 "eric7_iconeditor",
476 "eric7_ide", 477 "eric7_ide",
478 "eric7_mpy",
477 "eric7_pdf", 479 "eric7_pdf",
478 "eric7_pip", 480 "eric7_pip",
479 "eric7_plugininstall", 481 "eric7_plugininstall",
480 "eric7_pluginrepository", 482 "eric7_pluginrepository",
481 "eric7_pluginuninstall", 483 "eric7_pluginuninstall",
579 for name in [ 581 for name in [
580 "/usr/share/appdata/eric7.appdata.xml", 582 "/usr/share/appdata/eric7.appdata.xml",
581 "/usr/share/metainfo/eric7.appdata.xml", 583 "/usr/share/metainfo/eric7.appdata.xml",
582 "/usr/share/applications/eric7_browser.desktop", 584 "/usr/share/applications/eric7_browser.desktop",
583 "/usr/share/applications/eric7_ide.desktop", 585 "/usr/share/applications/eric7_ide.desktop",
586 "/usr/share/applications/eric7_mpy.desktop",
584 "/usr/share/icons/eric.png", 587 "/usr/share/icons/eric.png",
588 "/usr/share/icons/ericMPy.png",
585 "/usr/share/icons/ericWeb.png", 589 "/usr/share/icons/ericWeb.png",
586 "/usr/share/pixmaps/eric.png", 590 "/usr/share/pixmaps/eric.png",
591 "/usr/share/pixmaps/ericMPy.png",
587 "/usr/share/pixmaps/ericWeb.png", 592 "/usr/share/pixmaps/ericWeb.png",
588 # obsolete entries below 593 # obsolete entries below
589 "/usr/share/applications/eric7.desktop", 594 "/usr/share/applications/eric7.desktop",
590 ]: 595 ]:
591 if os.path.exists(name): 596 if os.path.exists(name):
595 for name in [ 600 for name in [
596 "~/.local/share/appdata/eric7.appdata.xml", 601 "~/.local/share/appdata/eric7.appdata.xml",
597 "~/.local/share/metainfo/eric7.appdata.xml", 602 "~/.local/share/metainfo/eric7.appdata.xml",
598 "~/.local/share/applications/eric7_browser.desktop", 603 "~/.local/share/applications/eric7_browser.desktop",
599 "~/.local/share/applications/eric7_ide.desktop", 604 "~/.local/share/applications/eric7_ide.desktop",
605 "~/.local/share/applications/eric7_mpy.desktop",
600 "~/.local/share/icons/eric.png", 606 "~/.local/share/icons/eric.png",
607 "~/.local/share/icons/ericMPy.png",
601 "~/.local/share/icons/ericWeb.png", 608 "~/.local/share/icons/ericWeb.png",
602 "~/.local/share/pixmaps/eric.png", 609 "~/.local/share/pixmaps/eric.png",
610 "~/.local/share/pixmaps/ericMPy.png",
603 "~/.local/share/pixmaps/ericWeb.png", 611 "~/.local/share/pixmaps/ericWeb.png",
604 # obsolete entries below 612 # obsolete entries below
605 "~/.local/share/applications/eric7.desktop", 613 "~/.local/share/applications/eric7.desktop",
606 ]: 614 ]:
607 path = os.path.expanduser(name) 615 path = os.path.expanduser(name)
716 "eric7_diff", 724 "eric7_diff",
717 "eric7_editor", 725 "eric7_editor",
718 "eric7_hexeditor", 726 "eric7_hexeditor",
719 "eric7_iconeditor", 727 "eric7_iconeditor",
720 "eric7_ide", 728 "eric7_ide",
729 "eric7_mpy",
721 "eric7_pdf", 730 "eric7_pdf",
722 "eric7_pip", 731 "eric7_pip",
723 "eric7_plugininstall", 732 "eric7_plugininstall",
724 "eric7_pluginrepository", 733 "eric7_pluginrepository",
725 "eric7_pluginuninstall", 734 "eric7_pluginuninstall",
934 global distDir, sourceDir 943 global distDir, sourceDir
935 944
936 dataSourceDir = os.path.join(eric7SourceDir, "data", "linux") 945 dataSourceDir = os.path.join(eric7SourceDir, "data", "linux")
937 946
938 if distDir: 947 if distDir:
948 # create directories first
949 for directory in (
950 os.path.normpath(os.path.join(distDir, name))
951 for name in (
952 "usr/share/icons",
953 "usr/share/icons/hicolor/48x48/apps",
954 "usr/share/applications",
955 "usr/share/metainfo",
956 "usr/share/appdata",
957 )
958 ):
959 if not os.path.exists(directory):
960 os.makedirs(directory)
961
939 dst = os.path.normpath(os.path.join(distDir, "usr/share/icons")) 962 dst = os.path.normpath(os.path.join(distDir, "usr/share/icons"))
940 if not os.path.exists(dst): 963 for icon in ("eric_icon.png", "ericMPy48_icon.png", "ericWeb48_icon.png"):
941 os.makedirs(dst) 964 shutilCopy(
942 shutilCopy( 965 os.path.join(eric7SourceDir, "pixmaps", icon),
943 os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"), 966 os.path.join(dst, icon.replace("_icon", "").replace("48", "")),
944 os.path.join(dst, "eric.png"), 967 )
945 )
946 shutilCopy(
947 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
948 os.path.join(dst, "ericWeb.png"),
949 )
950 968
951 dst = os.path.normpath( 969 dst = os.path.normpath(
952 os.path.join(distDir, "usr/share/icons/hicolor/48x48/apps") 970 os.path.join(distDir, "usr/share/icons/hicolor/48x48/apps")
953 ) 971 )
954 if not os.path.exists(dst): 972 for icon in ("eric48_icon.png", "ericMPy48_icon.png", "ericWeb48_icon.png"):
955 os.makedirs(dst) 973 shutilCopy(
956 shutilCopy( 974 os.path.join(eric7SourceDir, "pixmaps", icon),
957 os.path.join(eric7SourceDir, "pixmaps", "eric48_icon.png"), 975 os.path.join(dst, icon.replace("48_icon", "")),
958 os.path.join(dst, "eric.png"), 976 )
959 )
960 shutilCopy(
961 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
962 os.path.join(dst, "ericWeb.png"),
963 )
964 977
965 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications")) 978 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications"))
966 if not os.path.exists(dst): 979 for desktop in ("eric7_ide", "eric7_browser", "eric7_mpy"):
967 os.makedirs(dst) 980 copyDesktopFile(
968 copyDesktopFile( 981 os.path.join(dataSourceDir, desktop + ".desktop.in"),
969 os.path.join(dataSourceDir, "eric7_ide.desktop.in"), 982 os.path.join(dst, desktop + ".desktop"),
970 os.path.join(dst, "eric7_ide.desktop"), 983 )
971 ) 984
972 copyDesktopFile( 985 for dst in (
973 os.path.join(dataSourceDir, "eric7_browser.desktop.in"), 986 os.path.normpath(os.path.join(distDir, "usr/share/metainfo")),
974 os.path.join(dst, "eric7_browser.desktop"), 987 os.path.normpath(os.path.join(distDir, "usr/share/appdata")),
975 ) 988 ):
976 989 copyAppStreamFile(
977 dst = os.path.normpath(os.path.join(distDir, "usr/share/metainfo")) 990 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
978 if not os.path.exists(dst): 991 os.path.join(dst, "eric7.appdata.xml"),
979 os.makedirs(dst) 992 )
980 copyAppStreamFile( 993
981 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
982 os.path.join(dst, "eric7.appdata.xml"),
983 )
984 elif os.getuid() == 0: 994 elif os.getuid() == 0:
995 # eric meta data
985 shutilCopy( 996 shutilCopy(
986 os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"), 997 os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
987 "/usr/share/icons/eric.png", 998 "/usr/share/icons/eric.png",
988 ) 999 )
989 shutilCopy( 1000 shutilCopy(
1002 elif os.path.exists("/usr/share/appdata"): 1013 elif os.path.exists("/usr/share/appdata"):
1003 copyAppStreamFile( 1014 copyAppStreamFile(
1004 os.path.join(dataSourceDir, "eric7.appdata.xml.in"), 1015 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
1005 "/usr/share/appdata/eric7.appdata.xml", 1016 "/usr/share/appdata/eric7.appdata.xml",
1006 ) 1017 )
1018
1019 # eric MicroPython meta data
1020 shutilCopy(
1021 os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
1022 "/usr/share/icons/ericMPy.png",
1023 )
1024 shutilCopy(
1025 os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
1026 "/usr/share/icons/hicolor/48x48/apps/ericMPy.png",
1027 )
1028 copyDesktopFile(
1029 os.path.join(dataSourceDir, "eric7_mpy.desktop.in"),
1030 "/usr/share/applications/eric7_mpy.desktop",
1031 )
1032
1033 # eric web browser meta data
1007 shutilCopy( 1034 shutilCopy(
1008 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"), 1035 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
1009 "/usr/share/icons/ericWeb.png", 1036 "/usr/share/icons/ericWeb.png",
1010 ) 1037 )
1011 shutilCopy( 1038 shutilCopy(
1014 ) 1041 )
1015 copyDesktopFile( 1042 copyDesktopFile(
1016 os.path.join(dataSourceDir, "eric7_browser.desktop.in"), 1043 os.path.join(dataSourceDir, "eric7_browser.desktop.in"),
1017 "/usr/share/applications/eric7_browser.desktop", 1044 "/usr/share/applications/eric7_browser.desktop",
1018 ) 1045 )
1046
1019 elif os.getuid() >= 1000: 1047 elif os.getuid() >= 1000:
1020 # it is assumed, that user ids start at 1000 1048 # it is assumed, that user ids start at 1000
1021 localPath = os.path.join(os.path.expanduser("~"), ".local", "share") 1049 localPath = os.path.join(os.path.expanduser("~"), ".local", "share")
1022 # create directories first 1050 # create directories first
1023 for directory in [ 1051 for directory in [
1030 "appdata", 1058 "appdata",
1031 ) 1059 )
1032 ]: 1060 ]:
1033 if not os.path.isdir(directory): 1061 if not os.path.isdir(directory):
1034 os.makedirs(directory) 1062 os.makedirs(directory)
1063
1035 # now copy the files 1064 # now copy the files
1065 # eric meta data
1036 shutilCopy( 1066 shutilCopy(
1037 os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"), 1067 os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
1038 os.path.join(localPath, "icons", "eric.png"), 1068 os.path.join(localPath, "icons", "eric.png"),
1039 ) 1069 )
1040 shutilCopy( 1070 shutilCopy(
1051 ) 1081 )
1052 copyAppStreamFile( 1082 copyAppStreamFile(
1053 os.path.join(dataSourceDir, "eric7.appdata.xml.in"), 1083 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
1054 os.path.join(localPath, "appdata", "eric7.appdata.xml"), 1084 os.path.join(localPath, "appdata", "eric7.appdata.xml"),
1055 ) 1085 )
1086
1087 # eric MicroPython meta data
1088 shutilCopy(
1089 os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
1090 os.path.join(localPath, "icons", "ericMPy.png"),
1091 )
1092 shutilCopy(
1093 os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
1094 os.path.join(localPath, "icons/hicolor/48x48/apps", "ericMPy.png"),
1095 )
1096 copyDesktopFile(
1097 os.path.join(dataSourceDir, "eric7_mpy.desktop.in"),
1098 os.path.join(localPath, "applications", "eric7_mpy.desktop"),
1099 )
1100
1101 # eric web browser meta data
1056 shutilCopy( 1102 shutilCopy(
1057 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"), 1103 os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
1058 os.path.join(localPath, "icons", "ericWeb.png"), 1104 os.path.join(localPath, "icons", "ericWeb.png"),
1059 ) 1105 )
1060 shutilCopy( 1106 shutilCopy(
1735 1781
1736 if requiredMissing and optionalMissing: 1782 if requiredMissing and optionalMissing:
1737 print("Alternatively you may install all of them with:") 1783 print("Alternatively you may install all of them with:")
1738 print(" {0} install-dependencies.py --all".format(sys.executable)) 1784 print(" {0} install-dependencies.py --all".format(sys.executable))
1739 1785
1740 # determine the platform dependent black list 1786 # determine the platform dependent block list
1741 if sys.platform.startswith(("win", "cygwin")): 1787 if sys.platform.startswith(("win", "cygwin")):
1742 PlatformBlackLists = PlatformsBlackLists["windows"] 1788 PlatformBlockLists = PlatformsBlockLists["windows"]
1743 elif sys.platform.startswith("linux"): 1789 elif sys.platform.startswith("linux"):
1744 PlatformBlackLists = PlatformsBlackLists["linux"] 1790 PlatformBlockLists = PlatformsBlockLists["linux"]
1745 elif sys.platform.startswith("freebsd"): 1791 elif sys.platform.startswith("freebsd"):
1746 PlatformBlackLists = PlatformsBlackLists["freebsd"] 1792 PlatformBlockLists = PlatformsBlockLists["freebsd"]
1747 else: 1793 else:
1748 PlatformBlackLists = PlatformsBlackLists["mac"] 1794 PlatformBlockLists = PlatformsBlockLists["mac"]
1749 1795
1750 print("\nVersion Information") 1796 print("\nVersion Information")
1751 print("-------------------") 1797 print("-------------------")
1752 1798
1753 print("Python: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) 1799 print("Python: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
1777 " a recent development release.".format( 1823 " a recent development release.".format(
1778 versionToStr(requiredVersions["sip"]) 1824 versionToStr(requiredVersions["sip"])
1779 ) 1825 )
1780 ) 1826 )
1781 exit(3) 1827 exit(3)
1782 # check for blacklisted versions 1828 # check for blocklisted versions
1783 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 1829 for vers in BlockLists["sip"] + PlatformBlockLists["sip"]:
1784 if vers == sip.SIP_VERSION: 1830 if vers == sip.SIP_VERSION:
1785 print( 1831 print(
1786 "Sorry, sip version {0} is not compatible with eric.".format( 1832 "Sorry, sip version {0} is not compatible with eric.".format(
1787 versionToStr(vers) 1833 versionToStr(vers)
1788 ) 1834 )
1803 " a recent development release.".format( 1849 " a recent development release.".format(
1804 versionToStr(requiredVersions["pyqt6"]) 1850 versionToStr(requiredVersions["pyqt6"])
1805 ) 1851 )
1806 ) 1852 )
1807 exit(4) 1853 exit(4)
1808 # check for blacklisted versions 1854 # check for blocklisted versions
1809 for vers in BlackLists["PyQt6"] + PlatformBlackLists["PyQt6"]: 1855 for vers in BlockLists["PyQt6"] + PlatformBlockLists["PyQt6"]:
1810 if vers == PYQT_VERSION: 1856 if vers == PYQT_VERSION:
1811 print( 1857 print(
1812 "Sorry, PyQt version {0} is not compatible with eric.".format( 1858 "Sorry, PyQt version {0} is not compatible with eric.".format(
1813 versionToStr(vers) 1859 versionToStr(vers)
1814 ) 1860 )
1832 " a recent development release.".format( 1878 " a recent development release.".format(
1833 versionToStr(requiredVersions["pyqt6-qscintilla"]) 1879 versionToStr(requiredVersions["pyqt6-qscintilla"])
1834 ) 1880 )
1835 ) 1881 )
1836 exit(5) 1882 exit(5)
1837 # check for blacklisted versions 1883 # check for blocklisted versions
1838 for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]: 1884 for vers in BlockLists["QScintilla2"] + PlatformBlockLists["QScintilla2"]:
1839 if vers == QSCINTILLA_VERSION: 1885 if vers == QSCINTILLA_VERSION:
1840 print( 1886 print(
1841 "Sorry, QScintilla2 version {0} is not compatible with" 1887 "Sorry, QScintilla2 version {0} is not compatible with"
1842 " eric.".format(versionToStr(vers)) 1888 " eric.".format(versionToStr(vers))
1843 ) 1889 )
2067 entriesTemplates = [ 2113 entriesTemplates = [
2068 ( 2114 (
2069 "eric7 IDE (Python {0}.{1}).lnk", 2115 "eric7 IDE (Python {0}.{1}).lnk",
2070 os.path.join(cfg["bindir"], "eric7_ide.cmd"), 2116 os.path.join(cfg["bindir"], "eric7_ide.cmd"),
2071 os.path.join(cfg["ericPixDir"], "eric7.ico"), 2117 os.path.join(cfg["ericPixDir"], "eric7.ico"),
2118 ),
2119 (
2120 "eric7 MicroPython (Python {0}.{1}).lnk",
2121 os.path.join(cfg["bindir"], "eric7_mpy.cmd"),
2122 os.path.join(cfg["ericPixDir"], "ericMPy48.ico"),
2072 ), 2123 ),
2073 ( 2124 (
2074 "eric7 Browser (Python {0}.{1}).lnk", 2125 "eric7 Browser (Python {0}.{1}).lnk",
2075 os.path.join(cfg["bindir"], "eric7_browser.cmd"), 2126 os.path.join(cfg["bindir"], "eric7_browser.cmd"),
2076 os.path.join(cfg["ericPixDir"], "ericWeb48.ico"), 2127 os.path.join(cfg["ericPixDir"], "ericWeb48.ico"),

eric ide

mercurial