scripts/install.py

changeset 7257
c4d0cac9b5c9
parent 7229
53054eb5b15a
child 7286
7eb04391adf7
child 7288
1242c374623b
equal deleted inserted replaced
7256:4ef3b78ebb4e 7257:c4d0cac9b5c9
192 # install the eric scripts along the python executable 192 # install the eric scripts along the python executable
193 platBinDir = pyBinDir 193 platBinDir = pyBinDir
194 else: 194 else:
195 # install them in the user's bin directory 195 # install them in the user's bin directory
196 platBinDir = os.path.expanduser("~/bin") 196 platBinDir = os.path.expanduser("~/bin")
197 if platBinDir != "/usr/local/bin" and \ 197 if (
198 os.access("/usr/local/bin", os.W_OK): 198 platBinDir != "/usr/local/bin" and
199 os.access("/usr/local/bin", os.W_OK)
200 ):
199 platBinDirOld = "/usr/local/bin" 201 platBinDirOld = "/usr/local/bin"
200 202
201 modDir = distutils.sysconfig.get_python_lib(True) 203 modDir = distutils.sysconfig.get_python_lib(True)
202 pyModDir = modDir 204 pyModDir = modDir
203 205
274 276
275 f = open(src, "r", encoding="utf-8") 277 f = open(src, "r", encoding="utf-8")
276 text = f.read() 278 text = f.read()
277 f.close() 279 f.close()
278 280
279 text = text.replace("@MARKER@", "")\ 281 text = (
280 .replace("@VERSION@", Version.split(None, 1)[0])\ 282 text.replace("@MARKER@", "")
283 .replace("@VERSION@", Version.split(None, 1)[0])
281 .replace("@DATE@", time.strftime("%Y-%m-%d")) 284 .replace("@DATE@", time.strftime("%Y-%m-%d"))
285 )
282 286
283 f = open(dst, "w", encoding="utf-8") 287 f = open(dst, "w", encoding="utf-8")
284 f.write(text) 288 f.write(text)
285 f.close() 289 f.close()
286 os.chmod(dst, 0o644) 290 os.chmod(dst, 0o644)
317 """ 321 """
318 # all kinds of Windows systems 322 # all kinds of Windows systems
319 if sys.platform.startswith(("win", "cygwin")): 323 if sys.platform.startswith(("win", "cygwin")):
320 wname = wfile + ".cmd" 324 wname = wfile + ".cmd"
321 if isGuiScript: 325 if isGuiScript:
322 wrapper = \ 326 wrapper = (
323 '''@echo off\n''' \ 327 '''@echo off\n'''
324 '''start "" "{2}\\pythonw.exe"''' \ 328 '''start "" "{2}\\pythonw.exe"'''
325 ''' "{0}\\{1}.pyw"''' \ 329 ''' "{0}\\{1}.pyw"'''
326 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 330 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
327 pydir, wfile, sys.exec_prefix) 331 pydir, wfile, sys.exec_prefix)
332 )
328 else: 333 else:
329 wrapper = \ 334 wrapper = (
330 '''@"{0}\\python" "{1}\\{2}.py"''' \ 335 '''@"{0}\\python" "{1}\\{2}.py"'''
331 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 336 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
332 sys.exec_prefix, pydir, wfile) 337 sys.exec_prefix, pydir, wfile)
338 )
333 339
334 # Mac OS X 340 # Mac OS X
335 elif sys.platform == "darwin": 341 elif sys.platform == "darwin":
336 major = sys.version_info.major 342 major = sys.version_info.major
337 pyexec = "{0}/bin/pythonw{1}".format(sys.exec_prefix, major) 343 pyexec = "{0}/bin/pythonw{1}".format(sys.exec_prefix, major)
637 from pywintypes import com_error # __IGNORE_WARNING__ 643 from pywintypes import com_error # __IGNORE_WARNING__
638 except ImportError: 644 except ImportError:
639 # links were not created by install.py 645 # links were not created by install.py
640 return 646 return
641 647
642 regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \ 648 regPath = (
643 "\\User Shell Folders" 649 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" +
650 "\\User Shell Folders"
651 )
644 652
645 if doCleanDesktopLinks or forceCleanDesktopLinks: 653 if doCleanDesktopLinks or forceCleanDesktopLinks:
646 # 1. cleanup desktop links 654 # 1. cleanup desktop links
647 regName = "Desktop" 655 regName = "Desktop"
648 desktopEntry = getWinregEntry(regName, regPath) 656 desktopEntry = getWinregEntry(regName, regPath)
1005 "\nThe Python package 'pywin32' is not installed. Desktop and" 1013 "\nThe Python package 'pywin32' is not installed. Desktop and"
1006 " Start Menu entries will not be created." 1014 " Start Menu entries will not be created."
1007 ) 1015 )
1008 return 1016 return
1009 1017
1010 regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \ 1018 regPath = (
1011 "\\User Shell Folders" 1019 "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" +
1020 "\\User Shell Folders"
1021 )
1012 1022
1013 # 1. create desktop shortcuts 1023 # 1. create desktop shortcuts
1014 regName = "Desktop" 1024 regName = "Desktop"
1015 desktopFolder = os.path.normpath( 1025 desktopFolder = os.path.normpath(
1016 os.path.expandvars(getWinregEntry(regName, regPath))) 1026 os.path.expandvars(getWinregEntry(regName, regPath)))
1457 sipVersion += '.0' 1467 sipVersion += '.0'
1458 (major, minor, pat) = sipVersion.split('.') 1468 (major, minor, pat) = sipVersion.split('.')
1459 major = int(major) 1469 major = int(major)
1460 minor = int(minor) 1470 minor = int(minor)
1461 pat = int(pat) 1471 pat = int(pat)
1462 if major < 4 or (major == 4 and minor < 14) or \ 1472 if (
1463 (major == 4 and minor == 14 and pat < 2): 1473 major < 4 or
1474 (major == 4 and minor < 14) or
1475 (major == 4 and minor == 14 and pat < 2)
1476 ):
1464 print('Sorry, you must have sip 4.14.2 or higher or' 1477 print('Sorry, you must have sip 4.14.2 or higher or'
1465 ' a recent snapshot release.') 1478 ' a recent snapshot release.')
1466 exit(3) 1479 exit(3)
1467 # check for blacklisted versions 1480 # check for blacklisted versions
1468 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 1481 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
1514 if major < 2 or (major == 2 and minor < 9): 1527 if major < 2 or (major == 2 and minor < 9):
1515 print('Sorry, you must have QScintilla 2.9.0 or higher or' 1528 print('Sorry, you must have QScintilla 2.9.0 or higher or'
1516 ' a recent snapshot release.') 1529 ' a recent snapshot release.')
1517 exit(5) 1530 exit(5)
1518 # check for blacklisted versions 1531 # check for blacklisted versions
1519 for vers in BlackLists["QScintilla2"] + \ 1532 for vers in (
1520 PlatformBlackLists["QScintilla2"]: 1533 BlackLists["QScintilla2"] +
1534 PlatformBlackLists["QScintilla2"]
1535 ):
1521 if vers == scintillaVersion: 1536 if vers == scintillaVersion:
1522 print( 1537 print(
1523 'Sorry, QScintilla2 version {0} is not compatible with' 1538 'Sorry, QScintilla2 version {0} is not compatible with'
1524 ' eric6.'.format(vers)) 1539 ' eric6.'.format(vers))
1525 print('Please install another version.') 1540 print('Please install another version.')
1572 if hgOut.endswith("+"): 1587 if hgOut.endswith("+"):
1573 hgOut = hgOut[:-1] 1588 hgOut = hgOut[:-1]
1574 f = open(fileName + ".orig", "r", encoding="utf-8") 1589 f = open(fileName + ".orig", "r", encoding="utf-8")
1575 text = f.read() 1590 text = f.read()
1576 f.close() 1591 f.close()
1577 text = text.replace("@@REVISION@@", hgOut)\ 1592 text = (
1593 text.replace("@@REVISION@@", hgOut)
1578 .replace("@@VERSION@@", "rev_" + hgOut) 1594 .replace("@@VERSION@@", "rev_" + hgOut)
1595 )
1579 copyToFile(fileName, text) 1596 copyToFile(fileName, text)
1580 else: 1597 else:
1581 shutil.copy(fileName + ".orig", fileName) 1598 shutil.copy(fileName + ".orig", fileName)
1582 1599
1583 1600

eric ide

mercurial