571 |
571 |
572 global pyModDir, progLanguages |
572 global pyModDir, progLanguages |
573 |
573 |
574 # Remove the menu entry for Linux systems |
574 # Remove the menu entry for Linux systems |
575 if sys.platform.startswith("linux"): |
575 if sys.platform.startswith("linux"): |
576 if os.getuid() == 0: |
576 cleanUpLinuxSpecifics() |
577 for name in ["/usr/share/pixmaps/eric.png", |
|
578 "/usr/share/pixmaps/ericWeb.png"]: |
|
579 if os.path.exists(name): |
|
580 os.remove(name) |
|
581 if includePythonVariant: |
|
582 marker = PythonMarkers[sys.version_info.major] |
|
583 else: |
|
584 marker = "" |
|
585 for name in [ |
|
586 "/usr/share/applications/eric6" + marker + ".desktop", |
|
587 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
|
588 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
|
589 "/usr/share/applications/eric6_webbrowser" + marker + |
|
590 ".desktop", |
|
591 "/usr/share/applications/eric6_browser" + marker + |
|
592 ".desktop", |
|
593 "/usr/share/pixmaps/eric" + marker + ".png", |
|
594 "/usr/share/pixmaps/ericWeb" + marker + ".png", |
|
595 ]: |
|
596 if os.path.exists(name): |
|
597 os.remove(name) |
|
598 elif os.getuid() >= 1000: |
|
599 # it is assumed that user ids start at 1000 |
|
600 for name in ["~/.local/share/pixmaps/eric.png", |
|
601 "~/.local/share/pixmaps/ericWeb.png"]: |
|
602 path = os.path.expanduser(name) |
|
603 if os.path.exists(path): |
|
604 os.remove(path) |
|
605 if includePythonVariant: |
|
606 marker = PythonMarkers[sys.version_info.major] |
|
607 else: |
|
608 marker = "" |
|
609 for name in [ |
|
610 "~/.local/share/applications/eric6" + marker + ".desktop", |
|
611 "~/.local/share/appdata/eric6" + marker + ".appdata.xml", |
|
612 "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", |
|
613 "~/.local/share/applications/eric6_webbrowser" + marker + |
|
614 ".desktop", |
|
615 "~/.local/share/applications/eric6_browser" + marker + |
|
616 ".desktop", |
|
617 "~/.local/share/pixmaps/eric" + marker + ".png", |
|
618 "~/.local/share/pixmaps/ericWeb" + marker + ".png", |
|
619 ]: |
|
620 path = os.path.expanduser(name) |
|
621 if os.path.exists(path): |
|
622 os.remove(path) |
|
623 |
577 |
624 # Remove the wrapper scripts |
578 # Remove the wrapper scripts |
625 rem_wnames = [ |
579 rem_wnames = [ |
626 "eric6_api", "eric6_compare", |
580 "eric6_api", "eric6_compare", |
627 "eric6_configure", "eric6_diff", |
581 "eric6_configure", "eric6_diff", |
689 except AttributeError: |
643 except AttributeError: |
690 pass |
644 pass |
691 |
645 |
692 if sys.platform == "darwin": |
646 if sys.platform == "darwin": |
693 # delete the Mac app bundle |
647 # delete the Mac app bundle |
694 try: |
648 cleanUpMacAppBundle() |
695 macAppBundlePath = getConfig("macAppBundlePath") |
|
696 macAppBundleName = getConfig("macAppBundleName") |
|
697 except AttributeError: |
|
698 macAppBundlePath = defaultMacAppBundlePath |
|
699 macAppBundleName = defaultMacAppBundleName |
|
700 for bundlePath in [os.path.join(defaultMacAppBundlePath, |
|
701 macAppBundleName), |
|
702 os.path.join(macAppBundlePath, |
|
703 macAppBundleName), |
|
704 ]: |
|
705 if os.path.exists(bundlePath): |
|
706 shutil.rmtree(bundlePath) |
|
707 except (IOError, OSError) as msg: |
649 except (IOError, OSError) as msg: |
708 sys.stderr.write( |
650 sys.stderr.write( |
709 'Error: {0}\nTry install with admin rights.\n'.format(msg)) |
651 'Error: {0}\nTry install with admin rights.\n'.format(msg)) |
710 exit(7) |
652 exit(7) |
|
653 |
|
654 |
|
655 def cleanUpLinuxSpecifics(): |
|
656 """ |
|
657 Clean up Linux specific files. |
|
658 """ |
|
659 if os.getuid() == 0: |
|
660 for name in ["/usr/share/pixmaps/eric.png", |
|
661 "/usr/share/pixmaps/ericWeb.png"]: |
|
662 if os.path.exists(name): |
|
663 os.remove(name) |
|
664 if includePythonVariant: |
|
665 marker = PythonMarkers[sys.version_info.major] |
|
666 else: |
|
667 marker = "" |
|
668 for name in [ |
|
669 "/usr/share/applications/eric6" + marker + ".desktop", |
|
670 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
|
671 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
|
672 "/usr/share/applications/eric6_webbrowser" + marker + |
|
673 ".desktop", |
|
674 "/usr/share/applications/eric6_browser" + marker + |
|
675 ".desktop", |
|
676 "/usr/share/pixmaps/eric" + marker + ".png", |
|
677 "/usr/share/pixmaps/ericWeb" + marker + ".png", |
|
678 ]: |
|
679 if os.path.exists(name): |
|
680 os.remove(name) |
|
681 elif os.getuid() >= 1000: |
|
682 # it is assumed that user ids start at 1000 |
|
683 for name in ["~/.local/share/pixmaps/eric.png", |
|
684 "~/.local/share/pixmaps/ericWeb.png"]: |
|
685 path = os.path.expanduser(name) |
|
686 if os.path.exists(path): |
|
687 os.remove(path) |
|
688 if includePythonVariant: |
|
689 marker = PythonMarkers[sys.version_info.major] |
|
690 else: |
|
691 marker = "" |
|
692 for name in [ |
|
693 "~/.local/share/applications/eric6" + marker + ".desktop", |
|
694 "~/.local/share/appdata/eric6" + marker + ".appdata.xml", |
|
695 "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", |
|
696 "~/.local/share/applications/eric6_webbrowser" + marker + |
|
697 ".desktop", |
|
698 "~/.local/share/applications/eric6_browser" + marker + |
|
699 ".desktop", |
|
700 "~/.local/share/pixmaps/eric" + marker + ".png", |
|
701 "~/.local/share/pixmaps/ericWeb" + marker + ".png", |
|
702 ]: |
|
703 path = os.path.expanduser(name) |
|
704 if os.path.exists(path): |
|
705 os.remove(path) |
|
706 |
|
707 |
|
708 def cleanUpMacAppBundle(): |
|
709 """ |
|
710 Uninstall the macOS application bundle. |
|
711 """ |
|
712 from eric6config import getConfig |
|
713 try: |
|
714 macAppBundlePath = getConfig("macAppBundlePath") |
|
715 macAppBundleName = getConfig("macAppBundleName") |
|
716 except AttributeError: |
|
717 macAppBundlePath = defaultMacAppBundlePath |
|
718 macAppBundleName = defaultMacAppBundleName |
|
719 for bundlePath in [os.path.join(defaultMacAppBundlePath, |
|
720 macAppBundleName), |
|
721 os.path.join(macAppBundlePath, |
|
722 macAppBundleName), |
|
723 ]: |
|
724 if os.path.exists(bundlePath): |
|
725 shutil.rmtree(bundlePath) |
|
726 |
|
727 |
|
728 def cleanUpWindowsLinks(): |
|
729 """ |
|
730 Clean up the Desktop and Start Menu entries for Windows. |
|
731 """ |
711 |
732 |
712 |
733 |
713 def shutilCopy(src, dst, perm=0o644): |
734 def shutilCopy(src, dst, perm=0o644): |
714 """ |
735 """ |
715 Wrapper function around shutil.copy() to ensure the permissions. |
736 Wrapper function around shutil.copy() to ensure the permissions. |
900 shutilCopy(apiName, apidir) |
921 shutilCopy(apiName, apidir) |
901 except EnvironmentError: |
922 except EnvironmentError: |
902 print("Could not install '{0}' (no permission)." |
923 print("Could not install '{0}' (no permission)." |
903 .format(apiName)) |
924 .format(apiName)) |
904 |
925 |
905 # create menu entry for Linux systems |
926 # Create menu entry for Linux systems |
906 if sys.platform.startswith("linux"): |
927 if sys.platform.startswith("linux"): |
907 if includePythonVariant: |
928 createLinuxSpecifics() |
908 marker = PythonMarkers[sys.version_info.major] |
929 |
909 else: |
930 # Create Desktop and Start Menu entries for Windows systems |
910 marker = "" |
931 if sys.platform.startswith("win"): |
911 |
932 createWindowsLinks() |
912 if distDir: |
|
913 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) |
|
914 if not os.path.exists(dst): |
|
915 os.makedirs(dst) |
|
916 shutilCopy( |
|
917 os.path.join(sourceDir, "icons", "default", "eric.png"), |
|
918 os.path.join(dst, "eric" + marker + ".png")) |
|
919 shutilCopy( |
|
920 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), |
|
921 os.path.join(dst, "ericWeb" + marker + ".png")) |
|
922 dst = os.path.normpath( |
|
923 os.path.join(distDir, "usr/share/applications")) |
|
924 if not os.path.exists(dst): |
|
925 os.makedirs(dst) |
|
926 copyDesktopFile(os.path.join(sourceDir, "eric6.desktop"), |
|
927 os.path.join(dst, "eric6" + marker + ".desktop"), |
|
928 marker) |
|
929 copyDesktopFile( |
|
930 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
931 os.path.join(dst, "eric6_webbrowser" + marker + ".desktop"), |
|
932 marker) |
|
933 copyDesktopFile( |
|
934 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
935 os.path.join(dst, "eric6_browser" + marker + ".desktop"), |
|
936 marker) |
|
937 dst = os.path.normpath( |
|
938 os.path.join(distDir, "usr/share/metainfo")) |
|
939 if not os.path.exists(dst): |
|
940 os.makedirs(dst) |
|
941 copyAppStreamFile( |
|
942 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
943 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
|
944 marker) |
|
945 elif os.getuid() == 0: |
|
946 shutilCopy(os.path.join( |
|
947 sourceDir, "icons", "default", "eric.png"), |
|
948 "/usr/share/pixmaps/eric" + marker + ".png") |
|
949 copyDesktopFile( |
|
950 os.path.join(sourceDir, "eric6.desktop"), |
|
951 "/usr/share/applications/eric6" + marker + ".desktop", |
|
952 marker) |
|
953 if os.path.exists("/usr/share/metainfo"): |
|
954 copyAppStreamFile( |
|
955 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
956 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
|
957 marker) |
|
958 elif os.path.exists("/usr/share/appdata"): |
|
959 copyAppStreamFile( |
|
960 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
961 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
|
962 marker) |
|
963 shutilCopy(os.path.join( |
|
964 sourceDir, "icons", "default", "ericWeb48.png"), |
|
965 "/usr/share/pixmaps/ericWeb" + marker + ".png") |
|
966 copyDesktopFile( |
|
967 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
968 "/usr/share/applications/eric6_webbrowser" + marker + |
|
969 ".desktop", |
|
970 marker) |
|
971 copyDesktopFile( |
|
972 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
973 "/usr/share/applications/eric6_browser" + marker + |
|
974 ".desktop", |
|
975 marker) |
|
976 elif os.getuid() >= 1000: |
|
977 # it is assumed, that user ids start at 1000 |
|
978 localPath = os.path.join(os.path.expanduser("~"), |
|
979 ".local", "share") |
|
980 # create directories first |
|
981 for directory in [os.path.join(localPath, name) |
|
982 for name in ("pixmaps", "applications", |
|
983 "metainfo", "appdata")]: |
|
984 if not os.path.isdir(directory): |
|
985 os.makedirs(directory) |
|
986 # now copy the files |
|
987 shutilCopy( |
|
988 os.path.join(sourceDir, "icons", "default", "eric.png"), |
|
989 os.path.join(localPath, "pixmaps", "eric" + marker + ".png")) |
|
990 copyDesktopFile( |
|
991 os.path.join(sourceDir, "eric6.desktop"), |
|
992 os.path.join(localPath, "applications", |
|
993 "eric6" + marker + ".desktop"), |
|
994 marker) |
|
995 copyAppStreamFile( |
|
996 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
997 os.path.join(localPath, "metainfo", |
|
998 "eric6" + marker + ".appdata.xml"), |
|
999 marker) |
|
1000 copyAppStreamFile( |
|
1001 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
1002 os.path.join(localPath, "appdata", |
|
1003 "eric6" + marker + ".appdata.xml"), |
|
1004 marker) |
|
1005 shutilCopy( |
|
1006 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), |
|
1007 os.path.join(localPath, "pixmaps", |
|
1008 "ericWeb" + marker + ".png")) |
|
1009 copyDesktopFile( |
|
1010 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
1011 os.path.join(localPath, "applications", |
|
1012 "eric6_webbrowser" + marker + ".desktop"), |
|
1013 marker) |
|
1014 copyDesktopFile( |
|
1015 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
1016 os.path.join(localPath, "applications", |
|
1017 "eric6_browser" + marker + ".desktop"), |
|
1018 marker) |
|
1019 |
933 |
1020 # Create a Mac application bundle |
934 # Create a Mac application bundle |
1021 if sys.platform == "darwin": |
935 if sys.platform == "darwin": |
1022 createMacAppBundle(cfg['ericDir']) |
936 createMacAppBundle(cfg['ericDir']) |
1023 |
937 |
1024 return 0 |
938 return 0 |
1025 |
939 |
1026 |
940 |
|
941 def createLinuxSpecifics(): |
|
942 """ |
|
943 Install Linux specific files. |
|
944 """ |
|
945 global distDir, sourceDir, includePythonVariant |
|
946 |
|
947 if includePythonVariant: |
|
948 marker = PythonMarkers[sys.version_info.major] |
|
949 else: |
|
950 marker = "" |
|
951 |
|
952 if distDir: |
|
953 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) |
|
954 if not os.path.exists(dst): |
|
955 os.makedirs(dst) |
|
956 shutilCopy( |
|
957 os.path.join(sourceDir, "icons", "default", "eric.png"), |
|
958 os.path.join(dst, "eric" + marker + ".png")) |
|
959 shutilCopy( |
|
960 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), |
|
961 os.path.join(dst, "ericWeb" + marker + ".png")) |
|
962 dst = os.path.normpath( |
|
963 os.path.join(distDir, "usr/share/applications")) |
|
964 if not os.path.exists(dst): |
|
965 os.makedirs(dst) |
|
966 copyDesktopFile(os.path.join(sourceDir, "eric6.desktop"), |
|
967 os.path.join(dst, "eric6" + marker + ".desktop"), |
|
968 marker) |
|
969 copyDesktopFile( |
|
970 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
971 os.path.join(dst, "eric6_webbrowser" + marker + ".desktop"), |
|
972 marker) |
|
973 copyDesktopFile( |
|
974 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
975 os.path.join(dst, "eric6_browser" + marker + ".desktop"), |
|
976 marker) |
|
977 dst = os.path.normpath( |
|
978 os.path.join(distDir, "usr/share/metainfo")) |
|
979 if not os.path.exists(dst): |
|
980 os.makedirs(dst) |
|
981 copyAppStreamFile( |
|
982 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
983 os.path.join(dst, "eric6" + marker + ".appdata.xml"), |
|
984 marker) |
|
985 elif os.getuid() == 0: |
|
986 shutilCopy(os.path.join( |
|
987 sourceDir, "icons", "default", "eric.png"), |
|
988 "/usr/share/pixmaps/eric" + marker + ".png") |
|
989 copyDesktopFile( |
|
990 os.path.join(sourceDir, "eric6.desktop"), |
|
991 "/usr/share/applications/eric6" + marker + ".desktop", |
|
992 marker) |
|
993 if os.path.exists("/usr/share/metainfo"): |
|
994 copyAppStreamFile( |
|
995 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
996 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
|
997 marker) |
|
998 elif os.path.exists("/usr/share/appdata"): |
|
999 copyAppStreamFile( |
|
1000 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
1001 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
|
1002 marker) |
|
1003 shutilCopy(os.path.join( |
|
1004 sourceDir, "icons", "default", "ericWeb48.png"), |
|
1005 "/usr/share/pixmaps/ericWeb" + marker + ".png") |
|
1006 copyDesktopFile( |
|
1007 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
1008 "/usr/share/applications/eric6_webbrowser" + marker + |
|
1009 ".desktop", |
|
1010 marker) |
|
1011 copyDesktopFile( |
|
1012 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
1013 "/usr/share/applications/eric6_browser" + marker + |
|
1014 ".desktop", |
|
1015 marker) |
|
1016 elif os.getuid() >= 1000: |
|
1017 # it is assumed, that user ids start at 1000 |
|
1018 localPath = os.path.join(os.path.expanduser("~"), |
|
1019 ".local", "share") |
|
1020 # create directories first |
|
1021 for directory in [os.path.join(localPath, name) |
|
1022 for name in ("pixmaps", "applications", |
|
1023 "metainfo", "appdata")]: |
|
1024 if not os.path.isdir(directory): |
|
1025 os.makedirs(directory) |
|
1026 # now copy the files |
|
1027 shutilCopy( |
|
1028 os.path.join(sourceDir, "icons", "default", "eric.png"), |
|
1029 os.path.join(localPath, "pixmaps", "eric" + marker + ".png")) |
|
1030 copyDesktopFile( |
|
1031 os.path.join(sourceDir, "eric6.desktop"), |
|
1032 os.path.join(localPath, "applications", |
|
1033 "eric6" + marker + ".desktop"), |
|
1034 marker) |
|
1035 copyAppStreamFile( |
|
1036 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
1037 os.path.join(localPath, "metainfo", |
|
1038 "eric6" + marker + ".appdata.xml"), |
|
1039 marker) |
|
1040 copyAppStreamFile( |
|
1041 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
1042 os.path.join(localPath, "appdata", |
|
1043 "eric6" + marker + ".appdata.xml"), |
|
1044 marker) |
|
1045 shutilCopy( |
|
1046 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), |
|
1047 os.path.join(localPath, "pixmaps", |
|
1048 "ericWeb" + marker + ".png")) |
|
1049 copyDesktopFile( |
|
1050 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
1051 os.path.join(localPath, "applications", |
|
1052 "eric6_webbrowser" + marker + ".desktop"), |
|
1053 marker) |
|
1054 copyDesktopFile( |
|
1055 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
1056 os.path.join(localPath, "applications", |
|
1057 "eric6_browser" + marker + ".desktop"), |
|
1058 marker) |
|
1059 |
|
1060 |
|
1061 def createWindowsLinks(): |
|
1062 """ |
|
1063 Create Desktop and Start Menu links. |
|
1064 """ |
|
1065 try: |
|
1066 from win32com.client import Dispatch |
|
1067 except ImportError: |
|
1068 print( |
|
1069 "\nThe Python package 'pywin32' is not installed. Desktop and" |
|
1070 " Start Menu entries will not be created." |
|
1071 ) |
|
1072 return |
|
1073 |
|
1074 |
1027 def createMacAppBundle(pydir): |
1075 def createMacAppBundle(pydir): |
1028 """ |
1076 """ |
1029 Create a Mac application bundle. |
1077 Create a Mac application bundle. |
1030 |
1078 |
1031 @param pydir the name of the directory where the Python script will |
1079 @param pydir the name of the directory where the Python script will |
1032 eventually be installed (string) |
1080 eventually be installed |
|
1081 @type str |
1033 """ |
1082 """ |
1034 global cfg, sourceDir, macAppBundleName, macPythonExe, macAppBundlePath, \ |
1083 global cfg, sourceDir, macAppBundleName, macPythonExe, macAppBundlePath, \ |
1035 pyqtVariant |
1084 pyqtVariant |
1036 |
1085 |
1037 dirs = { |
1086 dirs = { |