install.py

changeset 2306
0f020f39977b
parent 2275
34804fc7e2f9
child 2307
1acbc8feb41a
equal deleted inserted replaced
2301:cfab9cb261d2 2306:0f020f39977b
31 doCompile = True 31 doCompile = True
32 cfg = {} 32 cfg = {}
33 progLanguages = ["Python", "Ruby"] 33 progLanguages = ["Python", "Ruby"]
34 sourceDir = "eric" 34 sourceDir = "eric"
35 configName = 'eric5config.py' 35 configName = 'eric5config.py'
36 macAppBundleName = "eric5.app"
37 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(sys.exec_prefix)
36 38
37 # Define blacklisted versions of the prerequisites 39 # Define blacklisted versions of the prerequisites
38 BlackLists = { 40 BlackLists = {
39 "sip": ["4.11", "4.12.3"], 41 "sip": ["4.11", "4.12.3"],
40 "PyQt4": ["4.7.5"], 42 "PyQt4": ["4.7.5"],
79 """ 81 """
80 Display a usage message and exit. 82 Display a usage message and exit.
81 83
82 @param rcode the return code passed back to the calling process. 84 @param rcode the return code passed back to the calling process.
83 """ 85 """
84 global progName, platBinDir, modDir, distDir, apisDir 86 global progName, platBinDir, modDir, distDir, apisDir, macAppBundleName
87 global macPythonExe
85 88
86 print() 89 print()
87 print("Usage:") 90 print("Usage:")
88 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\ 91 if sys.platform == "darwin":
92 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir] [-m name] [-p python]"\
93 .format(progName))
94 elif sys.platform.startswith("win"):
95 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\
96 .format(progName))
97 else:
98 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\
89 .format(progName)) 99 .format(progName))
90 print("where:") 100 print("where:")
91 print(" -h display this help message") 101 print(" -h display this help message")
92 print(" -a dir where the API files will be installed") 102 print(" -a dir where the API files will be installed")
93 if apisDir: 103 if apisDir:
100 print(" (default: {0})".format(modDir)) 110 print(" (default: {0})".format(modDir))
101 print(" -f file configuration file naming the various installation paths") 111 print(" -f file configuration file naming the various installation paths")
102 if not sys.platform.startswith("win"): 112 if not sys.platform.startswith("win"):
103 print(" -i dir temporary install prefix") 113 print(" -i dir temporary install prefix")
104 print(" (default: {0})".format(distDir)) 114 print(" (default: {0})".format(distDir))
115 if sys.platform == "darwin":
116 print(" -m name name of the Mac app bundle")
117 print(" (default: {0})".format(macAppBundleName))
118 print(" -p python name of the python executable")
119 print(" (default: {0})".format(macPythonExe))
105 print(" -x don't perform dependency checks (use on your own risk)") 120 print(" -x don't perform dependency checks (use on your own risk)")
106 print(" -c don't cleanup old installation first") 121 print(" -c don't cleanup old installation first")
107 print(" -z don't compile the installed python files") 122 print(" -z don't compile the installed python files")
108 print() 123 print()
109 print("The file given to the -f option must be valid Python code defining a") 124 print("The file given to the -f option must be valid Python code defining a")
291 306
292 def cleanUp(): 307 def cleanUp():
293 """ 308 """
294 Uninstall the old eric files. 309 Uninstall the old eric files.
295 """ 310 """
311 global macAppBundleName
312
296 try: 313 try:
297 from eric5config import getConfig 314 from eric5config import getConfig
298 except ImportError: 315 except ImportError:
299 # eric5 wasn't installed previously 316 # eric5 wasn't installed previously
300 return 317 return
378 395
379 if sys.platform == "darwin": 396 if sys.platform == "darwin":
380 # delete the Mac app bundle 397 # delete the Mac app bundle
381 if os.path.exists("/Developer/Applications/Eric5"): 398 if os.path.exists("/Developer/Applications/Eric5"):
382 shutil.rmtree("/Developer/Applications/Eric5") 399 shutil.rmtree("/Developer/Applications/Eric5")
383 if os.path.exists("/Applications/eric5.app"): 400 if os.path.exists("/Applications/" + macAppBundleName):
384 shutil.rmtree("/Applications/eric5.app") 401 shutil.rmtree("/Applications/" + macAppBundleName)
385 402
386 except IOError as msg: 403 except IOError as msg:
387 sys.stderr.write('IOError: {0}\nTry install with admin rights.\n'.format(msg)) 404 sys.stderr.write('IOError: {0}\nTry install with admin rights.\n'.format(msg))
388 exit(7) 405 exit(7)
389 406
583 Create a Mac application bundle. 600 Create a Mac application bundle.
584 601
585 @param pydir the name of the directory where the Python script will eventually 602 @param pydir the name of the directory where the Python script will eventually
586 be installed (string) 603 be installed (string)
587 """ 604 """
588 global cfg, sourceDir 605 global cfg, sourceDir, macAppBundleName, macPythonExe
589 606
590 dirs = {"contents": "/Applications/eric5.app/Contents/", 607 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName),
591 "exe": "/Applications/eric5.app/Contents/MacOS", 608 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName),
592 "icns": "/Applications/eric5.app/Contents/Resources"} 609 "icns": "/Applications/{0}/Contents/Resources".format(macAppBundleName)}
593 os.makedirs(dirs["contents"]) 610 os.makedirs(dirs["contents"])
594 os.mkdir(dirs["exe"]) 611 os.mkdir(dirs["exe"])
595 os.mkdir(dirs["icns"]) 612 os.mkdir(dirs["icns"])
596 613
597 starter = os.path.join(dirs["exe"], "eric") 614 ## starter = os.path.join(dirs["exe"], "eric")
598 os.symlink( 615 ## os.symlink(macPythonExe, starter)
599 "{0}/Resources/Python.app/Contents/MacOS/Python".format(sys.exec_prefix), 616 starter = "python3"
600 starter)
601 617
602 wname = os.path.join(dirs["exe"], "eric5") 618 wname = os.path.join(dirs["exe"], "eric5")
603 path = os.getenv("PATH", "") 619 path = os.getenv("PATH", "")
604 if path: 620 if path:
605 pybin = os.path.join(sys.exec_prefix, "bin") 621 pybin = os.path.join(sys.exec_prefix, "bin")
636 <key>CFBundleIconFile</key> 652 <key>CFBundleIconFile</key>
637 <string>eric.icns</string> 653 <string>eric.icns</string>
638 <key>CFBundleInfoDictionaryVersion</key> 654 <key>CFBundleInfoDictionaryVersion</key>
639 <string>1.0</string> 655 <string>1.0</string>
640 <key>CFBundleName</key> 656 <key>CFBundleName</key>
641 <string>eric5</string> 657 <string>{0}</string>
642 <key>CFBundlePackageType</key> 658 <key>CFBundlePackageType</key>
643 <string>APPL</string> 659 <string>APPL</string>
644 <key>CFBundleSignature</key> 660 <key>CFBundleSignature</key>
645 <string>????</string> 661 <string>????</string>
646 <key>CFBundleVersion</key> 662 <key>CFBundleVersion</key>
647 <string>1.0</string> 663 <string>1.0</string>
648 </dict> 664 </dict>
649 </plist> 665 </plist>
650 ''' 666 '''.format(macAppBundleName.replace(".app", ""))
651 ) 667 )
652 668
653 669
654 def createInstallConfig(): 670 def createInstallConfig():
655 """ 671 """
970 """ 986 """
971 import getopt 987 import getopt
972 988
973 # Parse the command line. 989 # Parse the command line.
974 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 990 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
975 global sourceDir, configName 991 global sourceDir, configName, macAppBundleName, macPythonExe
976 992
977 progName = os.path.basename(argv[0]) 993 progName = os.path.basename(argv[0])
978 994
979 if os.path.dirname(argv[0]): 995 if os.path.dirname(argv[0]):
980 os.chdir(os.path.dirname(argv[0])) 996 os.chdir(os.path.dirname(argv[0]))
982 initGlobals() 998 initGlobals()
983 999
984 try: 1000 try:
985 if sys.platform.startswith("win"): 1001 if sys.platform.startswith("win"):
986 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:") 1002 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:")
1003 elif sys.platform == "darwin":
1004 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:m:p:")
987 else: 1005 else:
988 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:") 1006 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:")
989 except getopt.GetoptError: 1007 except getopt.GetoptError:
990 usage() 1008 usage()
991 1009
1017 print("The configuration dictionary in '{0}' is incorrect. Aborting"\ 1035 print("The configuration dictionary in '{0}' is incorrect. Aborting"\
1018 .format(arg)) 1036 .format(arg))
1019 exit(6) 1037 exit(6)
1020 except: 1038 except:
1021 cfg = {} 1039 cfg = {}
1040 elif opt == "-m":
1041 macAppBundleName = arg
1042 elif opt == "-p":
1043 macPythonExe = arg
1022 1044
1023 installFromSource = not os.path.isdir(sourceDir) 1045 installFromSource = not os.path.isdir(sourceDir)
1024 if installFromSource: 1046 if installFromSource:
1025 sourceDir = os.path.dirname(__file__) or "." 1047 sourceDir = os.path.dirname(__file__) or "."
1026 configName = os.path.join(sourceDir, "eric5config.py") 1048 configName = os.path.join(sourceDir, "eric5config.py")

eric ide

mercurial