install.py

changeset 3935
f6ba54e022fa
parent 3931
ff8e034662d6
child 3936
93fb2fd523f1
equal deleted inserted replaced
3933:16d9ef6e6e89 3935:f6ba54e022fa
113 113
114 @param rcode the return code passed back to the calling process. 114 @param rcode the return code passed back to the calling process.
115 """ 115 """
116 global progName, modDir, distDir, apisDir 116 global progName, modDir, distDir, apisDir
117 global macAppBundleName, macAppBundlePath, macPythonExe 117 global macAppBundleName, macAppBundlePath, macPythonExe
118 global pyqtVariant
118 119
119 print() 120 print()
120 print("Usage:") 121 print("Usage:")
121 if sys.platform == "darwin": 122 if sys.platform == "darwin":
122 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 123 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
123 " [-m name] [-p python]".format(progName)) 124 " [-m name] [-p python] [--pyqt=version]".format(progName))
124 elif sys.platform.startswith("win"): 125 elif sys.platform.startswith("win"):
125 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]" 126 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]"
127 " [--pyqt=version]"
126 .format(progName)) 128 .format(progName))
127 else: 129 else:
128 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 130 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
131 " [--pyqt=version]"
129 .format(progName)) 132 .format(progName))
130 print("where:") 133 print("where:")
131 print(" -h display this help message") 134 print(" -h, --help display this help message")
132 print(" -a dir where the API files will be installed") 135 print(" -a dir where the API files will be installed")
133 if apisDir: 136 if apisDir:
134 print(" (default: {0})".format(apisDir)) 137 print(" (default: {0})".format(apisDir))
135 else: 138 else:
136 print(" (no default value)") 139 print(" (no default value)")
137 print(" -b dir where the binaries will be installed") 140 print(" -b dir where the binaries will be installed")
138 print(" (default: {0})".format(platBinDir)) 141 print(" (default: {0})".format(platBinDir))
139 print(" -d dir where eric6 python files will be installed") 142 print(" -d dir where eric6 python files will be installed")
140 print(" (default: {0})".format(modDir)) 143 print(" (default: {0})".format(modDir))
141 print(" -f file configuration file naming the various installation" 144 print(" -f file configuration file naming the various installation"
142 " paths") 145 " paths")
143 if not sys.platform.startswith("win"): 146 if not sys.platform.startswith("win"):
144 print(" -i dir temporary install prefix") 147 print(" -i dir temporary install prefix")
145 print(" (default: {0})".format(distDir)) 148 print(" (default: {0})".format(distDir))
146 if sys.platform == "darwin": 149 if sys.platform == "darwin":
147 print(" -m name name of the Mac app bundle") 150 print(" -m name name of the Mac app bundle")
148 print(" (default: {0})".format(macAppBundleName)) 151 print(" (default: {0})".format(macAppBundleName))
149 print(" -n path path of the directory the Mac app bundle will") 152 print(" -n path path of the directory the Mac app bundle will")
150 print(" be created in") 153 print(" be created in")
151 print(" (default: {0}".format(macAppBundlePath)) 154 print(" (default: {0})".format(macAppBundlePath))
152 print(" -p python name of the python executable") 155 print(" -p python name of the python executable")
153 print(" (default: {0})".format(macPythonExe)) 156 print(" (default: {0})".format(macPythonExe))
154 print(" -c don't cleanup old installation first") 157 print(" -c don't cleanup old installation first")
155 print(" -x don't perform dependency checks (use on your own" 158 print(" -x don't perform dependency checks (use on your own"
156 " risk)") 159 " risk)")
157 print(" -y add the Python variant to the executable names") 160 print(" -y add the Python variant to the executable names")
158 print(" -z don't compile the installed python files") 161 print(" -z don't compile the installed python files")
162 print(" --pyqt=version version of PyQt to be used (one of 4 or 5)")
163 print(" (default: {0})".format(pyqtVariant[-1]))
159 print() 164 print()
160 print("The file given to the -f option must be valid Python code" 165 print("The file given to the -f option must be valid Python code"
161 " defining a") 166 " defining a")
162 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir'," 167 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir',"
163 " 'ericIconDir',") 168 " 'ericIconDir',")
727 except EnvironmentError: 732 except EnvironmentError:
728 print("Could not install '{0}'.".format(apiName)) 733 print("Could not install '{0}'.".format(apiName))
729 734
730 # create menu entry for Linux systems 735 # create menu entry for Linux systems
731 if sys.platform.startswith("linux"): 736 if sys.platform.startswith("linux"):
732 # TODO: respect Python variant
733 if includePythonVariant: 737 if includePythonVariant:
734 marker = PythonMarkers[sys.version_info.major] 738 marker = PythonMarkers[sys.version_info.major]
735 else: 739 else:
736 marker = "" 740 marker = ""
737 741
1004 1008
1005 if pyqtVariant == "PyQt4": 1009 if pyqtVariant == "PyQt4":
1006 try: 1010 try:
1007 from PyQt4.QtCore import qVersion 1011 from PyQt4.QtCore import qVersion
1008 except ImportError as msg: 1012 except ImportError as msg:
1009 print('Sorry, please install PyQt5 or PyQt4.') 1013 print('Sorry, please install PyQt4.')
1010 print('Error: {0}'.format(msg)) 1014 print('Error: {0}'.format(msg))
1011 exit(1) 1015 exit(1)
1012 print("Found PyQt4") 1016 print("Found PyQt4")
1013 else: 1017 else:
1014 try: 1018 try:
1015 from PyQt5.QtCore import qVersion 1019 from PyQt5.QtCore import qVersion
1016 except ImportError as msg: 1020 except ImportError as msg:
1017 print('Sorry, please install PyQt5 or PyQt4.') 1021 print('Sorry, please install PyQt5.')
1018 print('Error: {0}'.format(msg)) 1022 print('Error: {0}'.format(msg))
1019 exit(1) 1023 exit(1)
1020 print("Found PyQt5") 1024 print("Found PyQt5")
1021 1025
1022 try: 1026 try:
1271 1275
1272 # Parse the command line. 1276 # Parse the command line.
1273 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1277 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1274 global sourceDir, configName, includePythonVariant 1278 global sourceDir, configName, includePythonVariant
1275 global macAppBundlePath, macAppBundleName, macPythonExe 1279 global macAppBundlePath, macAppBundleName, macPythonExe
1280 global pyqtVariant
1276 1281
1277 if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9): 1282 if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9):
1278 print('Sorry, eric6 requires at least Python 2.7 or ' 1283 print('Sorry, eric6 requires at least Python 2.7 or '
1279 'Python 3 for running.') 1284 'Python 3 for running.')
1280 exit(5) 1285 exit(5)
1287 determinePyQtVariant() 1292 determinePyQtVariant()
1288 initGlobals() 1293 initGlobals()
1289 1294
1290 try: 1295 try:
1291 if sys.platform.startswith("win"): 1296 if sys.platform.startswith("win"):
1292 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:") 1297 optlist, args = getopt.getopt(
1298 argv[1:], "chxyza:b:d:f:", ["help", "pyqt="])
1293 elif sys.platform == "darwin": 1299 elif sys.platform == "darwin":
1294 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:m:n:p:") 1300 optlist, args = getopt.getopt(
1301 argv[1:], "chxyza:b:d:f:i:m:n:p:", ["help", "pyqt="])
1295 else: 1302 else:
1296 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:") 1303 optlist, args = getopt.getopt(
1297 except getopt.GetoptError: 1304 argv[1:], "chxyza:b:d:f:i:", ["help", "pyqt="])
1305 except getopt.GetoptError as err:
1306 print(err)
1298 usage() 1307 usage()
1299 1308
1300 global platBinDir 1309 global platBinDir
1301 1310
1302 depChecks = True 1311 depChecks = True
1303 1312
1304 for opt, arg in optlist: 1313 for opt, arg in optlist:
1305 if opt == "-h": 1314 if opt in ["-h", "--help"]:
1306 usage(0) 1315 usage(0)
1307 elif opt == "-a": 1316 elif opt == "-a":
1308 apisDir = arg 1317 apisDir = arg
1309 elif opt == "-b": 1318 elif opt == "-b":
1310 platBinDir = arg 1319 platBinDir = arg
1333 macAppBundleName = arg 1342 macAppBundleName = arg
1334 elif opt == "-n": 1343 elif opt == "-n":
1335 macAppBundlePath = arg 1344 macAppBundlePath = arg
1336 elif opt == "-p": 1345 elif opt == "-p":
1337 macPythonExe = arg 1346 macPythonExe = arg
1347 elif opt == "--pyqt":
1348 if arg not in ["4", "5"]:
1349 print("Invalid PyQt version given; should be 4 or 5. Aborting")
1350 exit(6)
1351 pyqtVariant = "PyQt{0}".format(arg)
1338 1352
1339 installFromSource = not os.path.isdir(sourceDir) 1353 installFromSource = not os.path.isdir(sourceDir)
1340 if installFromSource: 1354 if installFromSource:
1341 sourceDir = os.path.dirname(__file__) or "." 1355 sourceDir = os.path.dirname(__file__) or "."
1342 configName = os.path.join(sourceDir, "eric6config.py") 1356 configName = os.path.join(sourceDir, "eric6config.py")

eric ide

mercurial