241 platBinDirOld = platBinDir |
241 platBinDirOld = platBinDir |
242 platBinDir = os.path.join(platBinDir, "Scripts") |
242 platBinDir = os.path.join(platBinDir, "Scripts") |
243 if not os.path.exists(platBinDir): |
243 if not os.path.exists(platBinDir): |
244 platBinDir = platBinDirOld |
244 platBinDir = platBinDirOld |
245 else: |
245 else: |
246 # TODO: install scripts into {venv}/bin for virtual environments |
246 pyBinDir = os.path.normpath(os.path.dirname(sys.executable)) |
247 # 1.) assume it is venv if os.path.dirname(sys.executable) is not in |
247 if os.access(pyBinDir, os.W_OK): |
248 # (/opt/local/bin, /usr/local/bin, /usr/bin) and |
248 # install the eric scripts along the python executable |
249 # 2.) directory is writable by user |
249 platBinDir = pyBinDir |
250 platBinDir = "/usr/local/bin" |
250 else: |
|
251 # install them in the user's bin directory |
|
252 platBinDir = os.path.expanduser("~/bin") |
|
253 if platBinDir != "/usr/local/bin" and \ |
|
254 os.access("/usr/local/bin", os.W_OK): |
|
255 platBinDirOld = "/usr/local/bin" |
251 |
256 |
252 modDir = distutils.sysconfig.get_python_lib(True) |
257 modDir = distutils.sysconfig.get_python_lib(True) |
253 pyModDir = modDir |
258 pyModDir = modDir |
254 |
259 |
255 pyqtDataDir = os.path.join(modDir, pyqtVariant) |
260 pyqtDataDir = os.path.join(modDir, pyqtVariant) |
256 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
261 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): |
257 # it's the installer |
262 # it's the installer |
258 qtDataDir = pyqtDataDir |
263 qtDataDir = pyqtDataDir |
259 else: |
264 elif os.path.exists(os.path.join(pyqtDataDir, "Qt", "qsci")): |
|
265 # it's the wheel |
|
266 qtDataDir = os.path.join(pyqtDataDir, "Qt") |
|
267 else: |
|
268 # determine dynamically |
260 try: |
269 try: |
261 if pyqtVariant == "PyQt4": |
270 if pyqtVariant == "PyQt4": |
262 from PyQt4.QtCore import QLibraryInfo |
271 from PyQt4.QtCore import QLibraryInfo |
263 else: |
272 else: |
264 from PyQt5.QtCore import QLibraryInfo |
273 from PyQt5.QtCore import QLibraryInfo |
549 return |
558 return |
550 |
559 |
551 global pyModDir, progLanguages |
560 global pyModDir, progLanguages |
552 |
561 |
553 # Remove the menu entry for Linux systems |
562 # Remove the menu entry for Linux systems |
554 if sys.platform.startswith("linux") and os.getuid() == 0: |
563 if sys.platform.startswith("linux"): |
555 for name in ["/usr/share/pixmaps/eric.png", |
564 if os.getuid() == 0: |
556 "/usr/share/pixmaps/ericWeb.png"]: |
565 for name in ["/usr/share/pixmaps/eric.png", |
557 if os.path.exists(name): |
566 "/usr/share/pixmaps/ericWeb.png"]: |
558 os.remove(name) |
567 if os.path.exists(name): |
559 if includePythonVariant: |
568 os.remove(name) |
560 marker = PythonMarkers[sys.version_info.major] |
569 if includePythonVariant: |
561 else: |
570 marker = PythonMarkers[sys.version_info.major] |
562 marker = "" |
571 else: |
563 for name in ["/usr/share/applications/eric6" + marker + ".desktop", |
572 marker = "" |
564 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
573 for name in [ |
565 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
574 "/usr/share/applications/eric6" + marker + ".desktop", |
566 "/usr/share/applications/eric6_webbrowser" + marker + |
575 "/usr/share/appdata/eric6" + marker + ".appdata.xml", |
567 ".desktop", |
576 "/usr/share/metainfo/eric6" + marker + ".appdata.xml", |
568 "/usr/share/applications/eric6_browser" + marker + |
577 "/usr/share/applications/eric6_webbrowser" + marker + |
569 ".desktop", |
578 ".desktop", |
570 ]: |
579 "/usr/share/applications/eric6_browser" + marker + |
571 if os.path.exists(name): |
580 ".desktop", |
572 os.remove(name) |
581 "/usr/share/pixmaps/eric" + marker + ".png", |
|
582 "/usr/share/pixmaps/ericWeb" + marker + ".png", |
|
583 ]: |
|
584 if os.path.exists(name): |
|
585 os.remove(name) |
|
586 elif os.getuid() >= 1000: |
|
587 # it is assumed that user ids start at 1000 |
|
588 for name in ["~/.local/share/pixmaps/eric.png", |
|
589 "~/.local/share/pixmaps/ericWeb.png"]: |
|
590 path = os.path.expanduser(name) |
|
591 if os.path.exists(path): |
|
592 os.remove(path) |
|
593 if includePythonVariant: |
|
594 marker = PythonMarkers[sys.version_info.major] |
|
595 else: |
|
596 marker = "" |
|
597 for name in [ |
|
598 "~/.local/share/applications/eric6" + marker + ".desktop", |
|
599 "~/.local/share/appdata/eric6" + marker + ".appdata.xml", |
|
600 "~/.local/share/metainfo/eric6" + marker + ".appdata.xml", |
|
601 "~/.local/share/applications/eric6_webbrowser" + marker + |
|
602 ".desktop", |
|
603 "~/.local/share/applications/eric6_browser" + marker + |
|
604 ".desktop", |
|
605 "~/.local/share/pixmaps/eric" + marker + ".png", |
|
606 "~/.local/share/pixmaps/ericWeb" + marker + ".png", |
|
607 ]: |
|
608 path = os.path.expanduser(name) |
|
609 if os.path.exists(path): |
|
610 os.remove(path) |
573 |
611 |
574 # Remove the wrapper scripts |
612 # Remove the wrapper scripts |
575 rem_wnames = [ |
613 rem_wnames = [ |
576 "eric6_api", "eric6_compare", |
614 "eric6_api", "eric6_compare", |
577 "eric6_configure", "eric6_diff", |
615 "eric6_configure", "eric6_diff", |
600 if os.path.exists(rwname): |
638 if os.path.exists(rwname): |
601 os.remove(rwname) |
639 os.remove(rwname) |
602 |
640 |
603 # Cleanup our config file(s) |
641 # Cleanup our config file(s) |
604 for name in ['eric6config.py', 'eric6config.pyc', 'eric6.pth']: |
642 for name in ['eric6config.py', 'eric6config.pyc', 'eric6.pth']: |
605 e5cfile = os.path.join(pyModDir, name) |
643 e6cfile = os.path.join(pyModDir, name) |
606 if os.path.exists(e5cfile): |
644 if os.path.exists(e6cfile): |
607 os.remove(e5cfile) |
645 os.remove(e6cfile) |
608 e5cfile = os.path.join(pyModDir, "__pycache__", name) |
646 e5cfile = os.path.join(pyModDir, "__pycache__", name) |
609 path, ext = os.path.splitext(e5cfile) |
647 path, ext = os.path.splitext(e5cfile) |
610 for f in glob.glob("{0}.*{1}".format(path, ext)): |
648 for f in glob.glob("{0}.*{1}".format(path, ext)): |
611 os.remove(f) |
649 os.remove(f) |
612 |
650 |
812 |
850 |
813 # install the API file |
851 # install the API file |
814 if installApis: |
852 if installApis: |
815 for progLanguage in progLanguages: |
853 for progLanguage in progLanguages: |
816 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) |
854 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) |
|
855 print("Installing {0} API files to '{1}'.".format( |
|
856 progLanguage, apidir)) |
817 if not os.path.exists(apidir): |
857 if not os.path.exists(apidir): |
818 os.makedirs(apidir) |
858 os.makedirs(apidir) |
819 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
859 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
820 progLanguage, "*.api")): |
860 progLanguage, "*.api")): |
821 try: |
861 try: |
822 shutilCopy(apiName, apidir) |
862 shutilCopy(apiName, apidir) |
823 except EnvironmentError: |
863 except EnvironmentError: |
824 print("Could not install '{0}'.".format(apiName)) |
864 print("Could not install '{0}' (no permission)." |
|
865 .format(apiName)) |
825 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
866 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
826 progLanguage, "*.bas")): |
867 progLanguage, "*.bas")): |
827 try: |
868 try: |
828 shutilCopy(apiName, apidir) |
869 shutilCopy(apiName, apidir) |
829 except EnvironmentError: |
870 except EnvironmentError: |
830 print("Could not install '{0}'.".format(apiName)) |
871 print("Could not install '{0}' (no permission)." |
|
872 .format(apiName)) |
831 if progLanguage == "Python": |
873 if progLanguage == "Python": |
832 # copy Python3 API files to the same destination |
874 # copy Python3 API files to the same destination |
833 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
875 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
834 "Python3", "*.api")): |
876 "Python3", "*.api")): |
835 try: |
877 try: |
836 shutilCopy(apiName, apidir) |
878 shutilCopy(apiName, apidir) |
837 except EnvironmentError: |
879 except EnvironmentError: |
838 print("Could not install '{0}'.".format(apiName)) |
880 print("Could not install '{0}' (no permission)." |
|
881 .format(apiName)) |
839 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
882 for apiName in glob.glob(os.path.join(sourceDir, "APIs", |
840 "Python3", "*.bas")): |
883 "Python3", "*.bas")): |
841 if os.path.exists(os.path.join( |
884 if os.path.exists(os.path.join( |
842 apidir, os.path.basename( |
885 apidir, os.path.basename( |
843 apiName.replace(".bas", ".api")))): |
886 apiName.replace(".bas", ".api")))): |
844 try: |
887 try: |
845 shutilCopy(apiName, apidir) |
888 shutilCopy(apiName, apidir) |
846 except EnvironmentError: |
889 except EnvironmentError: |
847 print("Could not install '{0}'.".format(apiName)) |
890 print("Could not install '{0}' (no permission)." |
|
891 .format(apiName)) |
848 |
892 |
849 # create menu entry for Linux systems |
893 # create menu entry for Linux systems |
850 if sys.platform.startswith("linux"): |
894 if sys.platform.startswith("linux"): |
851 if includePythonVariant: |
895 if includePythonVariant: |
852 marker = PythonMarkers[sys.version_info.major] |
896 marker = PythonMarkers[sys.version_info.major] |
915 copyDesktopFile( |
959 copyDesktopFile( |
916 os.path.join(sourceDir, "eric6_browser.desktop"), |
960 os.path.join(sourceDir, "eric6_browser.desktop"), |
917 "/usr/share/applications/eric6_browser" + marker + |
961 "/usr/share/applications/eric6_browser" + marker + |
918 ".desktop", |
962 ".desktop", |
919 marker) |
963 marker) |
|
964 elif os.getuid() >= 1000: |
|
965 # it is assumed, that user ids start at 1000 |
|
966 localPath = os.path.join(os.path.expanduser("~"), ".local") |
|
967 # create directories first |
|
968 for directory in [os.path.join(localPath, name) |
|
969 for name in ("pixmaps", "applications", |
|
970 "metainfo", "appdata")]: |
|
971 if not os.path.isdir(directory): |
|
972 os.makedirs(directory) |
|
973 # now copy the files |
|
974 shutilCopy( |
|
975 os.path.join(sourceDir, "icons", "default", "eric.png"), |
|
976 os.path.join(localPath, "pixmaps", "eric" + marker + ".png")) |
|
977 copyDesktopFile( |
|
978 os.path.join(sourceDir, "eric6.desktop"), |
|
979 os.path.join(localPath, "applications", |
|
980 "eric6" + marker + ".desktop"), |
|
981 marker) |
|
982 copyAppStreamFile( |
|
983 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
984 os.path.join(localPath, "metainfo", |
|
985 "eric6" + marker + ".appdata.xml"), |
|
986 marker) |
|
987 copyAppStreamFile( |
|
988 os.path.join(sourceDir, "eric6.appdata.xml"), |
|
989 os.path.join(localPath, "appdata", |
|
990 "eric6" + marker + ".appdata.xml"), |
|
991 marker) |
|
992 shutilCopy( |
|
993 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), |
|
994 os.path.join(localPath, "pixmaps", |
|
995 "ericWeb" + marker + ".png")) |
|
996 copyDesktopFile( |
|
997 os.path.join(sourceDir, "eric6_webbrowser.desktop"), |
|
998 os.path.join(localPath, "applications", |
|
999 "eric6_webbrowser" + marker + ".desktop"), |
|
1000 marker) |
|
1001 copyDesktopFile( |
|
1002 os.path.join(sourceDir, "eric6_browser.desktop"), |
|
1003 os.path.join(localPath, "applications", |
|
1004 "eric6_browser" + marker + ".desktop"), |
|
1005 marker) |
920 |
1006 |
921 # Create a Mac application bundle |
1007 # Create a Mac application bundle |
922 if sys.platform == "darwin": |
1008 if sys.platform == "darwin": |
923 createMacAppBundle(cfg['ericDir']) |
1009 createMacAppBundle(cfg['ericDir']) |
924 |
1010 |