install.py

branch
5_5_x
changeset 3932
a909b9212f59
parent 3900
8c12501b6b48
child 3941
f8a9af3d8b56
equal deleted inserted replaced
3930:2968e0bfcaea 3932:a909b9212f59
215 text = codecs.encode(text, "utf-8") 215 text = codecs.encode(text, "utf-8")
216 f.write(text) 216 f.write(text)
217 f.close() 217 f.close()
218 218
219 219
220 def copyDesktopFile(src, dst, marker):
221 """
222 Modify a desktop file and write it to its destination.
223
224 @param src source file name (string)
225 @param dst destination file name (string)
226 @param marker marker to be used (string)
227 """
228 f = open(src, "r")
229 text = f.read()
230 f.close()
231
232 text = text.replace("@MARKER@", marker)
233
234 f = open(dst, "w")
235 f.write(text)
236 f.close()
237 os.chmod(dst, 0o644)
238
239
220 def wrapperName(dname, wfile): 240 def wrapperName(dname, wfile):
221 """ 241 """
222 Create the platform specific name for the wrapper script. 242 Create the platform specific name for the wrapper script.
223 243
224 @param dname name of the directory to place the wrapper into 244 @param dname name of the directory to place the wrapper into
405 global pyModDir, progLanguages 425 global pyModDir, progLanguages
406 426
407 # Remove the menu entry for Linux systems 427 # Remove the menu entry for Linux systems
408 if sys.platform.startswith("linux") and os.getuid() == 0: 428 if sys.platform.startswith("linux") and os.getuid() == 0:
409 for name in ["/usr/share/pixmaps/eric.png", 429 for name in ["/usr/share/pixmaps/eric.png",
410 "/usr/share/applications/eric5.desktop", 430 "/usr/share/pixmaps/ericWeb.png"]:
411 "/usr/share/appdata/eric5.appdata.xml", 431 if os.path.exists(name):
412 "/usr/share/pixmaps/ericWeb.png", 432 os.remove(name)
413 "/usr/share/applications/eric5_webbrowser.desktop"]: 433 if includePythonVariant:
434 marker = PythonMarkers[sys.version_info.major]
435 else:
436 marker = ""
437 for name in ["/usr/share/applications/eric5" + marker + ".desktop",
438 "/usr/share/appdata/eric5" + marker + ".appdata.xml",
439 "/usr/share/applications/eric5_webbrowser" + marker +
440 ".desktop"]:
414 if os.path.exists(name): 441 if os.path.exists(name):
415 os.remove(name) 442 os.remove(name)
416 443
417 # Remove the wrapper scripts 444 # Remove the wrapper scripts
418 rem_wnames = [ 445 rem_wnames = [
485 apiname = os.path.join(apidir, progLanguage.lower(), name) 512 apiname = os.path.join(apidir, progLanguage.lower(), name)
486 if os.path.exists(apiname): 513 if os.path.exists(apiname):
487 os.remove(apiname) 514 os.remove(apiname)
488 for apiname in glob.glob( 515 for apiname in glob.glob(
489 os.path.join(apidir, progLanguage.lower(), "*.bas")): 516 os.path.join(apidir, progLanguage.lower(), "*.bas")):
490 if os.path.basename(apiname) != "eric6.bas": 517 if os.path.basename(apiname) != "eric5.bas":
491 os.remove(apiname) 518 os.remove(apiname)
492 except AttributeError: 519 except AttributeError:
493 pass 520 pass
494 521
495 if sys.platform == "darwin": 522 if sys.platform == "darwin":
534 Actually perform the installation steps. 561 Actually perform the installation steps.
535 562
536 @return result code (integer) 563 @return result code (integer)
537 """ 564 """
538 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName 565 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
566 global includePythonVariant
539 567
540 # Create the platform specific wrappers. 568 # Create the platform specific wrappers.
541 wnames = [] 569 wnames = []
542 for name in ["eric5_api", "eric5_doc"]: 570 for name in ["eric5_api", "eric5_doc"]:
543 wnames.append(createPyWrapper(cfg['ericDir'], name, False)) 571 wnames.append(createPyWrapper(cfg['ericDir'], name, False))
702 except EnvironmentError: 730 except EnvironmentError:
703 print("Could not install '{0}'.".format(apiName)) 731 print("Could not install '{0}'.".format(apiName))
704 732
705 # create menu entry for Linux systems 733 # create menu entry for Linux systems
706 if sys.platform.startswith("linux"): 734 if sys.platform.startswith("linux"):
735 if includePythonVariant:
736 marker = PythonMarkers[sys.version_info.major]
737 else:
738 marker = ""
739
707 if distDir: 740 if distDir:
708 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) 741 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
709 if not os.path.exists(dst): 742 if not os.path.exists(dst):
710 os.makedirs(dst) 743 os.makedirs(dst)
711 shutilCopy( 744 shutilCopy(
716 os.path.join(dst, "ericWeb.png")) 749 os.path.join(dst, "ericWeb.png"))
717 dst = os.path.normpath( 750 dst = os.path.normpath(
718 os.path.join(distDir, "usr/share/applications")) 751 os.path.join(distDir, "usr/share/applications"))
719 if not os.path.exists(dst): 752 if not os.path.exists(dst):
720 os.makedirs(dst) 753 os.makedirs(dst)
721 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst) 754 copyDesktopFile(os.path.join(sourceDir, "eric5.desktop"),
722 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"), 755 os.path.join(dst, "eric5" + marker + ".desktop"),
723 dst) 756 marker)
757 copyDesktopFile(
758 os.path.join(sourceDir, "eric5_webbrowser.desktop"),
759 os.path.join(dst, "eric5_webbrowser" + marker + ".desktop"),
760 marker)
724 dst = os.path.normpath( 761 dst = os.path.normpath(
725 os.path.join(distDir, "usr/share/appdata")) 762 os.path.join(distDir, "usr/share/appdata"))
726 if not os.path.exists(dst): 763 if not os.path.exists(dst):
727 os.makedirs(dst) 764 os.makedirs(dst)
728 shutilCopy(os.path.join(sourceDir, "eric5.appdata.xml"), dst) 765 copyDesktopFile(
766 os.path.join(sourceDir, "eric5.appdata.xml"),
767 os.path.join(dst, "eric5" + marker + ".appdata.xml"),
768 marker)
729 elif os.getuid() == 0: 769 elif os.getuid() == 0:
730 shutilCopy(os.path.join( 770 shutilCopy(os.path.join(
731 sourceDir, "icons", "default", "eric.png"), 771 sourceDir, "icons", "default", "eric.png"),
732 "/usr/share/pixmaps/eric.png") 772 "/usr/share/pixmaps/eric.png")
733 shutilCopy(os.path.join( 773 copyDesktopFile(
734 sourceDir, "eric5.desktop"), 774 os.path.join(sourceDir, "eric5.desktop"),
735 "/usr/share/applications") 775 "/usr/share/applications/eric5" + marker + ".desktop",
776 marker)
736 if os.path.exists("/usr/share/appdata"): 777 if os.path.exists("/usr/share/appdata"):
737 shutilCopy(os.path.join( 778 copyDesktopFile(
738 sourceDir, "eric5.appdata.xml"), 779 os.path.join(sourceDir, "eric5.appdata.xml"),
739 "/usr/share/appdata") 780 "/usr/share/appdata/eric5" + marker + ".appdata.xml",
781 marker)
740 shutilCopy(os.path.join( 782 shutilCopy(os.path.join(
741 sourceDir, "icons", "default", "ericWeb48.png"), 783 sourceDir, "icons", "default", "ericWeb48.png"),
742 "/usr/share/pixmaps/ericWeb.png") 784 "/usr/share/pixmaps/ericWeb.png")
743 shutilCopy(os.path.join( 785 copyDesktopFile(
744 sourceDir, "eric5_webbrowser.desktop"), 786 os.path.join(sourceDir, "eric5_webbrowser.desktop"),
745 "/usr/share/applications") 787 "/usr/share/applications/eric5_webbrowser" + marker +
788 ".desktop",
789 marker)
746 790
747 # Create a Mac application bundle 791 # Create a Mac application bundle
748 if sys.platform == "darwin": 792 if sys.platform == "darwin":
749 createMacAppBundle(cfg['ericDir']) 793 createMacAppBundle(cfg['ericDir'])
750 794

eric ide

mercurial