install.py

changeset 3931
ff8e034662d6
parent 3897
ae4d4d69ad40
child 3935
f6ba54e022fa
equal deleted inserted replaced
3929:e5bbf088b01d 3931:ff8e034662d6
236 text = codecs.encode(text, "utf-8") 236 text = codecs.encode(text, "utf-8")
237 f.write(text) 237 f.write(text)
238 f.close() 238 f.close()
239 239
240 240
241 def copyDesktopFile(src, dst, marker):
242 """
243 Modify a desktop file and write it to its destination.
244
245 @param src source file name (string)
246 @param dst destination file name (string)
247 @param marker marker to be used (string)
248 """
249 f = open(src, "r")
250 text = f.read()
251 f.close()
252
253 text = text.replace("@MARKER@", marker)
254
255 f = open(dst, "w")
256 f.write(text)
257 f.close()
258 os.chmod(dst, 0o644)
259
260
241 def wrapperName(dname, wfile): 261 def wrapperName(dname, wfile):
242 """ 262 """
243 Create the platform specific name for the wrapper script. 263 Create the platform specific name for the wrapper script.
244 264
245 @param dname name of the directory to place the wrapper into 265 @param dname name of the directory to place the wrapper into
426 global pyModDir, progLanguages 446 global pyModDir, progLanguages
427 447
428 # Remove the menu entry for Linux systems 448 # Remove the menu entry for Linux systems
429 if sys.platform.startswith("linux") and os.getuid() == 0: 449 if sys.platform.startswith("linux") and os.getuid() == 0:
430 for name in ["/usr/share/pixmaps/eric.png", 450 for name in ["/usr/share/pixmaps/eric.png",
431 "/usr/share/applications/eric6.desktop", 451 "/usr/share/pixmaps/ericWeb.png"]:
432 "/usr/share/appdata/eric6.appdata.xml", 452 if os.path.exists(name):
433 "/usr/share/pixmaps/ericWeb.png", 453 os.remove(name)
434 "/usr/share/applications/eric6_webbrowser.desktop"]: 454 if includePythonVariant:
455 marker = PythonMarkers[sys.version_info.major]
456 else:
457 marker = ""
458 for name in ["/usr/share/applications/eric6" + marker + ".desktop",
459 "/usr/share/appdata/eric6" + marker + ".appdata.xml",
460 "/usr/share/applications/eric6_webbrowser" + marker +
461 ".desktop"]:
435 if os.path.exists(name): 462 if os.path.exists(name):
436 os.remove(name) 463 os.remove(name)
437 464
438 # Remove the wrapper scripts 465 # Remove the wrapper scripts
439 rem_wnames = [ 466 rem_wnames = [
539 Actually perform the installation steps. 566 Actually perform the installation steps.
540 567
541 @return result code (integer) 568 @return result code (integer)
542 """ 569 """
543 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName 570 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
571 global includePythonVariant
544 572
545 # Create the platform specific wrappers. 573 # Create the platform specific wrappers.
546 wnames = [] 574 wnames = []
547 for name in ["eric6_api", "eric6_doc"]: 575 for name in ["eric6_api", "eric6_doc"]:
548 wnames.append(createPyWrapper(cfg['ericDir'], name, False)) 576 wnames.append(createPyWrapper(cfg['ericDir'], name, False))
699 except EnvironmentError: 727 except EnvironmentError:
700 print("Could not install '{0}'.".format(apiName)) 728 print("Could not install '{0}'.".format(apiName))
701 729
702 # create menu entry for Linux systems 730 # create menu entry for Linux systems
703 if sys.platform.startswith("linux"): 731 if sys.platform.startswith("linux"):
732 # TODO: respect Python variant
733 if includePythonVariant:
734 marker = PythonMarkers[sys.version_info.major]
735 else:
736 marker = ""
737
704 if distDir: 738 if distDir:
705 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) 739 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
706 if not os.path.exists(dst): 740 if not os.path.exists(dst):
707 os.makedirs(dst) 741 os.makedirs(dst)
708 shutilCopy( 742 shutilCopy(
713 os.path.join(dst, "ericWeb.png")) 747 os.path.join(dst, "ericWeb.png"))
714 dst = os.path.normpath( 748 dst = os.path.normpath(
715 os.path.join(distDir, "usr/share/applications")) 749 os.path.join(distDir, "usr/share/applications"))
716 if not os.path.exists(dst): 750 if not os.path.exists(dst):
717 os.makedirs(dst) 751 os.makedirs(dst)
718 shutilCopy(os.path.join(sourceDir, "eric6.desktop"), dst) 752 copyDesktopFile(os.path.join(sourceDir, "eric6.desktop"),
719 shutilCopy(os.path.join(sourceDir, "eric6_webbrowser.desktop"), 753 os.path.join(dst, "eric6" + marker + ".desktop"),
720 dst) 754 marker)
755 copyDesktopFile(
756 os.path.join(sourceDir, "eric6_webbrowser.desktop"),
757 os.path.join(dst, "eric6_webbrowser" + marker + ".desktop"),
758 marker)
721 dst = os.path.normpath( 759 dst = os.path.normpath(
722 os.path.join(distDir, "usr/share/appdata")) 760 os.path.join(distDir, "usr/share/appdata"))
723 if not os.path.exists(dst): 761 if not os.path.exists(dst):
724 os.makedirs(dst) 762 os.makedirs(dst)
725 shutilCopy(os.path.join(sourceDir, "eric6.appdata.xml"), dst) 763 copyDesktopFile(
764 os.path.join(sourceDir, "eric6.appdata.xml"),
765 os.path.join(dst, "eric6" + marker + ".appdata.xml"),
766 marker)
726 elif os.getuid() == 0: 767 elif os.getuid() == 0:
727 shutilCopy(os.path.join( 768 shutilCopy(os.path.join(
728 sourceDir, "icons", "default", "eric.png"), 769 sourceDir, "icons", "default", "eric.png"),
729 "/usr/share/pixmaps/eric.png") 770 "/usr/share/pixmaps/eric.png")
730 shutilCopy(os.path.join( 771 copyDesktopFile(
731 sourceDir, "eric6.desktop"), 772 os.path.join(sourceDir, "eric6.desktop"),
732 "/usr/share/applications") 773 "/usr/share/applications/eric6" + marker + ".desktop",
774 marker)
733 if os.path.exists("/usr/share/appdata"): 775 if os.path.exists("/usr/share/appdata"):
734 shutilCopy(os.path.join( 776 copyDesktopFile(
735 sourceDir, "eric6.appdata.xml"), 777 os.path.join(sourceDir, "eric6.appdata.xml"),
736 "/usr/share/appdata") 778 "/usr/share/appdata/eric6" + marker + ".appdata.xml",
779 marker)
737 shutilCopy(os.path.join( 780 shutilCopy(os.path.join(
738 sourceDir, "icons", "default", "ericWeb48.png"), 781 sourceDir, "icons", "default", "ericWeb48.png"),
739 "/usr/share/pixmaps/ericWeb.png") 782 "/usr/share/pixmaps/ericWeb.png")
740 shutilCopy(os.path.join( 783 copyDesktopFile(
741 sourceDir, "eric6_webbrowser.desktop"), 784 os.path.join(sourceDir, "eric6_webbrowser.desktop"),
742 "/usr/share/applications") 785 "/usr/share/applications/eric6_webbrowser" + marker +
786 ".desktop",
787 marker)
743 788
744 # Create a Mac application bundle 789 # Create a Mac application bundle
745 if sys.platform == "darwin": 790 if sys.platform == "darwin":
746 createMacAppBundle(cfg['ericDir']) 791 createMacAppBundle(cfg['ericDir'])
747 792

eric ide

mercurial