install.py

branch
maintenance
changeset 6319
df201b9fbad4
parent 6316
ee88310f0334
child 6322
cb7d2ab9c9f5
equal deleted inserted replaced
6274:44249d49d892 6319:df201b9fbad4
27 import compileall 27 import compileall
28 import py_compile 28 import py_compile
29 import glob 29 import glob
30 import shutil 30 import shutil
31 import fnmatch 31 import fnmatch
32 import distutils.sysconfig
33 import codecs 32 import codecs
34 import subprocess 33 import subprocess
35 import time 34 import time
36 35
37 # Define the globals. 36 # Define the globals.
231 """ 230 """
232 Module function to set the values of globals that need more than a 231 Module function to set the values of globals that need more than a
233 simple assignment. 232 simple assignment.
234 """ 233 """
235 global platBinDir, modDir, pyModDir, apisDir, pyqtVariant, platBinDirOld 234 global platBinDir, modDir, pyModDir, apisDir, pyqtVariant, platBinDirOld
236 235
236 try:
237 import distutils.sysconfig
238 except ImportError:
239 print("Please install the 'distutils' package first.")
240 exit(5)
241
237 if sys.platform.startswith("win"): 242 if sys.platform.startswith("win"):
238 platBinDir = sys.exec_prefix 243 platBinDir = sys.exec_prefix
239 if platBinDir.endswith("\\"): 244 if platBinDir.endswith("\\"):
240 platBinDir = platBinDir[:-1] 245 platBinDir = platBinDir[:-1]
241 platBinDirOld = platBinDir 246 platBinDirOld = platBinDir
300 305
301 @param src source file name (string) 306 @param src source file name (string)
302 @param dst destination file name (string) 307 @param dst destination file name (string)
303 @param marker marker to be used (string) 308 @param marker marker to be used (string)
304 """ 309 """
305 global cfg 310 global cfg, platBinDir
306 311
307 if sys.version_info[0] == 2: 312 if sys.version_info[0] == 2:
308 f = codecs.open(src, "r", "utf-8") 313 f = codecs.open(src, "r", "utf-8")
309 else: 314 else:
310 f = open(src, "r", encoding="utf-8") 315 f = open(src, "r", encoding="utf-8")
311 text = f.read() 316 text = f.read()
312 f.close() 317 f.close()
313 318
314 text = text.replace("@BINDIR@", cfg['bindir']) 319 text = text.replace("@BINDIR@", platBinDir)
315 text = text.replace("@MARKER@", marker) 320 text = text.replace("@MARKER@", marker)
316 if marker: 321 if marker:
317 t_marker = " ({0})".format(PythonTextMarkers[marker]) 322 t_marker = " ({0})".format(PythonTextMarkers[marker])
318 else: 323 else:
319 t_marker = "" 324 t_marker = ""
1233 @type str 1238 @type str
1234 @return flag indicating a successful installation 1239 @return flag indicating a successful installation
1235 @rtype bool 1240 @rtype bool
1236 """ 1241 """
1237 ok = False 1242 ok = False
1238 print(message, "\n") 1243 print("{0}\n\nShall '{1}' be installed using pip? (Y/n)"
1239 answer = input("Shall '{0}' be installed using pip? (Y/n) " 1244 .format(message, packageName), end=" ")
1240 .format(packageName)) 1245 answer = input()
1241 if answer in ("", "Y", "y"): 1246 if answer in ("", "Y", "y"):
1242 exitCode = subprocess.call( 1247 exitCode = subprocess.call(
1243 [sys.executable, "-m", "pip", "install", packageName]) 1248 [sys.executable, "-m", "pip", "install", packageName])
1244 ok = (exitCode == 0) 1249 ok = (exitCode == 0)
1245 1250

eric ide

mercurial