scripts/install.py

branch
maintenance
changeset 8043
0acf98cd089a
parent 7924
8a96736d465e
parent 7960
e8fc383322f7
child 8142
43248bafe9b2
equal deleted inserted replaced
7991:866adc8c315b 8043:0acf98cd089a
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> 4 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5 # 5 #
6 # This is the install script for eric6. 6 # This is the install script for eric.
7 7
8 """ 8 """
9 Installation script for the eric6 IDE and all eric6 related tools. 9 Installation script for the eric IDE and all eric related tools.
10 """ 10 """
11 11
12 import sys 12 import sys
13 import os 13 import os
14 import re 14 import re
141 else: 141 else:
142 print(" (no default value)") 142 print(" (no default value)")
143 print(" --no-apis don't install API files") 143 print(" --no-apis don't install API files")
144 print(" -b dir where the binaries will be installed") 144 print(" -b dir where the binaries will be installed")
145 print(" (default: {0})".format(platBinDir)) 145 print(" (default: {0})".format(platBinDir))
146 print(" -d dir where eric6 python files will be installed") 146 print(" -d dir where eric python files will be installed")
147 print(" (default: {0})".format(modDir)) 147 print(" (default: {0})".format(modDir))
148 print(" -f file configuration file naming the various installation" 148 print(" -f file configuration file naming the various installation"
149 " paths") 149 " paths")
150 if not sys.platform.startswith(("win", "cygwin")): 150 if not sys.platform.startswith(("win", "cygwin")):
151 print(" -i dir temporary install prefix") 151 print(" -i dir temporary install prefix")
177 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir'," 177 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir',"
178 " 'ericExamplesDir',") 178 " 'ericExamplesDir',")
179 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',") 179 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',")
180 print("'ericOthersDir','bindir', 'mdir' and 'apidir.") 180 print("'ericOthersDir','bindir', 'mdir' and 'apidir.")
181 print("These define the directories for the installation of the various" 181 print("These define the directories for the installation of the various"
182 " parts of eric6.") 182 " parts of eric.")
183 183
184 exit(rcode) 184 exit(rcode)
185 185
186 186
187 def initGlobals(): 187 def initGlobals():
385 385
386 @param src name of the source directory 386 @param src name of the source directory
387 @param dst name of the destination directory 387 @param dst name of the destination directory
388 @param filters list of filter pattern determining the files to be copied 388 @param filters list of filter pattern determining the files to be copied
389 @param excludeDirs list of (sub)directories to exclude from copying 389 @param excludeDirs list of (sub)directories to exclude from copying
390 @keyparam excludePatterns list of filter pattern determining the files to 390 @param excludePatterns list of filter pattern determining the files to
391 be skipped 391 be skipped
392 """ 392 """
393 if excludeDirs is None: 393 if excludeDirs is None:
394 excludeDirs = [] 394 excludeDirs = []
395 if excludePatterns is None: 395 if excludePatterns is None:
491 global platBinDir, platBinDirOld 491 global platBinDir, platBinDirOld
492 492
493 try: 493 try:
494 from eric6config import getConfig 494 from eric6config import getConfig
495 except ImportError: 495 except ImportError:
496 # eric6 wasn't installed previously 496 # eric wasn't installed previously
497 return 497 return
498 except SyntaxError: 498 except SyntaxError:
499 # an incomplete or old config file was found 499 # an incomplete or old config file was found
500 return 500 return
501 501
696 """ 696 """
697 Wrapper function around shutil.copy() to ensure the permissions. 697 Wrapper function around shutil.copy() to ensure the permissions.
698 698
699 @param src source file name (string) 699 @param src source file name (string)
700 @param dst destination file name or directory name (string) 700 @param dst destination file name or directory name (string)
701 @keyparam perm permissions to be set (integer) 701 @param perm permissions to be set (integer)
702 """ 702 """
703 shutil.copy(src, dst) 703 shutil.copy(src, dst)
704 if os.path.isdir(dst): 704 if os.path.isdir(dst):
705 dst = os.path.join(dst, os.path.basename(src)) 705 dst = os.path.join(dst, os.path.basename(src))
706 os.chmod(dst, perm) 706 os.chmod(dst, perm)
742 # make the install directories 742 # make the install directories
743 for key in cfg.keys(): 743 for key in cfg.keys():
744 if cfg[key] and not os.path.isdir(cfg[key]): 744 if cfg[key] and not os.path.isdir(cfg[key]):
745 os.makedirs(cfg[key]) 745 os.makedirs(cfg[key])
746 746
747 # copy the eric6 config file 747 # copy the eric config file
748 if distDir: 748 if distDir:
749 shutilCopy(configName, cfg['mdir']) 749 shutilCopy(configName, cfg['mdir'])
750 if os.path.exists(configName + 'c'): 750 if os.path.exists(configName + 'c'):
751 shutilCopy(configName + 'c', cfg['mdir']) 751 shutilCopy(configName + 'c', cfg['mdir'])
752 else: 752 else:
753 shutilCopy(configName, modDir) 753 shutilCopy(configName, modDir)
754 if os.path.exists(configName + 'c'): 754 if os.path.exists(configName + 'c'):
755 shutilCopy(configName + 'c', modDir) 755 shutilCopy(configName + 'c', modDir)
756 756
757 # copy the various parts of eric6 757 # copy the various parts of eric
758 copyTree( 758 copyTree(
759 eric6SourceDir, cfg['ericDir'], 759 eric6SourceDir, cfg['ericDir'],
760 ['*.py', '*.pyc', '*.pyo', '*.pyw'], 760 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
761 [os.path.join(sourceDir, "Examples"), 761 [os.path.join(sourceDir, "Examples"),
762 os.path.join(sourceDir, ".ropeproject")], 762 os.path.join(sourceDir, ".ropeproject")],
1255 else: 1255 else:
1256 macConfig = "" 1256 macConfig = ""
1257 config = ( 1257 config = (
1258 """# -*- coding: utf-8 -*-\n""" 1258 """# -*- coding: utf-8 -*-\n"""
1259 """#\n""" 1259 """#\n"""
1260 """# This module contains the configuration of the individual eric6""" 1260 """# This module contains the configuration of the individual eric"""
1261 """ installation\n""" 1261 """ installation\n"""
1262 """#\n""" 1262 """#\n"""
1263 """\n""" 1263 """\n"""
1264 """_pkg_config = {{\n""" 1264 """_pkg_config = {{\n"""
1265 """ 'ericDir': r'{0}',\n""" 1265 """ 'ericDir': r'{0}',\n"""
1312 copyToFile(configName, config) 1312 copyToFile(configName, config)
1313 1313
1314 1314
1315 def createInstallInfo(): 1315 def createInstallInfo():
1316 """ 1316 """
1317 Record information about the way eric6 was installed. 1317 Record information about the way eric was installed.
1318 """ 1318 """
1319 global createInstallInfoFile, installInfo, installCwd, cfg 1319 global createInstallInfoFile, installInfo, installCwd, cfg
1320 1320
1321 if createInstallInfoFile: 1321 if createInstallInfoFile:
1322 installDateTime = datetime.datetime.now(tz=None) 1322 installDateTime = datetime.datetime.now(tz=None)
1433 updatePip() 1433 updatePip()
1434 print("\n") 1434 print("\n")
1435 1435
1436 # perform dependency checks 1436 # perform dependency checks
1437 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) 1437 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
1438 if sys.version_info < (3, 5, 0): 1438 if sys.version_info < (3, 6, 0):
1439 print('Sorry, you must have Python 3.5.0 or higher.') 1439 print('Sorry, you must have Python 3.6.0 or higher.')
1440 exit(5) 1440 exit(5)
1441 1441
1442 try: 1442 try:
1443 import xml.etree # __IGNORE_WARNING__ 1443 import xml.etree # __IGNORE_WARNING__
1444 except ImportError: 1444 except ImportError:
1630 exit(3) 1630 exit(3)
1631 # check for blacklisted versions 1631 # check for blacklisted versions
1632 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 1632 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
1633 if vers == sipVersion: 1633 if vers == sipVersion:
1634 print( 1634 print(
1635 'Sorry, sip version {0} is not compatible with eric6.' 1635 'Sorry, sip version {0} is not compatible with eric.'
1636 .format(vers)) 1636 .format(vers))
1637 print('Please install another version.') 1637 print('Please install another version.')
1638 exit(3) 1638 exit(3)
1639 except (ImportError, AttributeError): 1639 except (ImportError, AttributeError):
1640 pass 1640 pass
1656 ' a recent snapshot release.') 1656 ' a recent snapshot release.')
1657 exit(4) 1657 exit(4)
1658 # check for blacklisted versions 1658 # check for blacklisted versions
1659 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]: 1659 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]:
1660 if vers == pyqtVersion: 1660 if vers == pyqtVersion:
1661 print('Sorry, PyQt version {0} is not compatible with eric6.' 1661 print('Sorry, PyQt version {0} is not compatible with eric.'
1662 .format(vers)) 1662 .format(vers))
1663 print('Please install another version.') 1663 print('Please install another version.')
1664 exit(4) 1664 exit(4)
1665 1665
1666 # check version of QScintilla 1666 # check version of QScintilla
1689 PlatformBlackLists["QScintilla2"] 1689 PlatformBlackLists["QScintilla2"]
1690 ): 1690 ):
1691 if vers == scintillaVersion: 1691 if vers == scintillaVersion:
1692 print( 1692 print(
1693 'Sorry, QScintilla2 version {0} is not compatible with' 1693 'Sorry, QScintilla2 version {0} is not compatible with'
1694 ' eric6.'.format(vers)) 1694 ' eric.'.format(vers))
1695 print('Please install another version.') 1695 print('Please install another version.')
1696 exit(5) 1696 exit(5)
1697 1697
1698 # print version info for additional modules 1698 # print version info for additional modules
1699 try: 1699 try:
1877 global macAppBundlePath, macAppBundleName, macPythonExe 1877 global macAppBundlePath, macAppBundleName, macPythonExe
1878 global installApis, doCleanDesktopLinks, yes2All 1878 global installApis, doCleanDesktopLinks, yes2All
1879 global createInstallInfoFile, installCwd 1879 global createInstallInfoFile, installCwd
1880 global ignorePyqt5Tools 1880 global ignorePyqt5Tools
1881 1881
1882 if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99): 1882 if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99):
1883 print('Sorry, eric6 requires at least Python 3.5 for running.') 1883 print('Sorry, eric requires at least Python 3.6 for running.')
1884 exit(5) 1884 exit(5)
1885 1885
1886 progName = os.path.basename(argv[0]) 1886 progName = os.path.basename(argv[0])
1887 1887
1888 installCwd = os.getcwd() 1888 installCwd = os.getcwd()
2042 rx=skipRe, 2042 rx=skipRe,
2043 quiet=True) 2043 quiet=True)
2044 py_compile.compile(configName, 2044 py_compile.compile(configName,
2045 dfile=os.path.join(modDir, "eric6config.py")) 2045 dfile=os.path.join(modDir, "eric6config.py"))
2046 sys.stdout = sys.__stdout__ 2046 sys.stdout = sys.__stdout__
2047 print("\nInstalling eric6 ...") 2047 print("\nInstalling eric ...")
2048 res = installEric() 2048 res = installEric()
2049 2049
2050 if createInstallInfoFile: 2050 if createInstallInfoFile:
2051 with open(os.path.join(cfg["ericDir"], 2051 with open(os.path.join(cfg["ericDir"],
2052 installInfoName), "w") as installInfoFile: 2052 installInfoName), "w") as installInfoFile:

eric ide

mercurial