scripts/install.py

changeset 7804
1cbc27e34ec6
parent 7799
5aeb0122e063
child 7806
b346755b09a1
equal deleted inserted replaced
7803:97f77d69c6f0 7804:1cbc27e34ec6
49 if not os.path.exists(defaultMacPythonExe): 49 if not os.path.exists(defaultMacPythonExe):
50 defaultMacPythonExe = "" 50 defaultMacPythonExe = ""
51 macAppBundleName = defaultMacAppBundleName 51 macAppBundleName = defaultMacAppBundleName
52 macAppBundlePath = defaultMacAppBundlePath 52 macAppBundlePath = defaultMacAppBundlePath
53 macPythonExe = defaultMacPythonExe 53 macPythonExe = defaultMacPythonExe
54
55 installInfoName = "eric6install.json"
56 installInfo = {}
54 57
55 # Define blacklisted versions of the prerequisites 58 # Define blacklisted versions of the prerequisites
56 BlackLists = { 59 BlackLists = {
57 "sip": [], 60 "sip": [],
58 "PyQt5": [], 61 "PyQt5": [],
1231 for apiName in sorted( 1234 for apiName in sorted(
1232 glob.glob(os.path.join(eric6SourceDir, "APIs", 1235 glob.glob(os.path.join(eric6SourceDir, "APIs",
1233 "MicroPython", "*.api"))): 1236 "MicroPython", "*.api"))):
1234 apis.append(os.path.basename(apiName)) 1237 apis.append(os.path.basename(apiName))
1235 1238
1239 if sys.platform == "darwin":
1240 macConfig = (
1241 """ 'macAppBundlePath': r'{0}',\n"""
1242 """ 'macAppBundleName': r'{1}',\n"""
1243 ).format(macAppBundlePath, macAppBundleName)
1244 else:
1245 macConfig = ""
1236 config = ( 1246 config = (
1237 """# -*- coding: utf-8 -*-\n""" 1247 """# -*- coding: utf-8 -*-\n"""
1238 """#\n""" 1248 """#\n"""
1239 """# This module contains the configuration of the individual eric6""" 1249 """# This module contains the configuration of the individual eric6"""
1240 """ installation\n""" 1250 """ installation\n"""
1255 """ 'ericOthersDir': r'{11}',\n""" 1265 """ 'ericOthersDir': r'{11}',\n"""
1256 """ 'bindir': r'{12}',\n""" 1266 """ 'bindir': r'{12}',\n"""
1257 """ 'mdir': r'{13}',\n""" 1267 """ 'mdir': r'{13}',\n"""
1258 """ 'apidir': r'{14}',\n""" 1268 """ 'apidir': r'{14}',\n"""
1259 """ 'apis': {15},\n""" 1269 """ 'apis': {15},\n"""
1260 """ 'macAppBundlePath': r'{16}',\n""" 1270 """{16}"""
1261 """ 'macAppBundleName': r'{17}',\n"""
1262 """}}\n""" 1271 """}}\n"""
1263 """\n""" 1272 """\n"""
1264 """def getConfig(name):\n""" 1273 """def getConfig(name):\n"""
1265 """ '''\n""" 1274 """ '''\n"""
1266 """ Module function to get a configuration value.\n""" 1275 """ Module function to get a configuration value.\n"""
1285 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 1294 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
1286 cfg['ericTemplatesDir'], 1295 cfg['ericTemplatesDir'],
1287 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 1296 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
1288 cfg['bindir'], cfg['mdir'], 1297 cfg['bindir'], cfg['mdir'],
1289 cfg['apidir'], sorted(apis), 1298 cfg['apidir'], sorted(apis),
1290 macAppBundlePath, macAppBundleName, 1299 macConfig,
1291 ) 1300 )
1292 copyToFile(configName, config) 1301 copyToFile(configName, config)
1302
1303
1304 def createInstallInfo():
1305 """
1306 Record information about the way eric6 was installed.
1307 """
1308 global installInfo, cfg
1309
1310 try:
1311 installInfo["sudo"] = os.getuid() == 0
1312 except AttributeError:
1313 installInfo["sudo"] = False
1314 installInfo["user"] = os.getlogin()
1315 installInfo["exe"] = sys.executable
1316 installInfo["argv"] = sys.argv[:]
1317 installInfo["eric"] = cfg["ericDir"]
1318 installInfo["virtualenv"] = installInfo["eric"].startswith(
1319 os.path.expanduser("~"))
1320 installInfo["installed"] = True
1321 installInfo["guessed"] = False
1322 installInfo["edited"] = False
1323 installInfo["pip"] = False
1324 installInfo["remarks"] = ""
1293 1325
1294 1326
1295 def pipInstall(packageName, message): 1327 def pipInstall(packageName, message):
1296 """ 1328 """
1297 Install the given package via pip. 1329 Install the given package via pip.
1934 1966
1935 # Create a config file and delete the default one 1967 # Create a config file and delete the default one
1936 print("\nCreating configuration file ...") 1968 print("\nCreating configuration file ...")
1937 createConfig() 1969 createConfig()
1938 1970
1971 createInstallInfo()
1972
1939 # Compile .ui files 1973 # Compile .ui files
1940 print("\nCompiling user interface files ...") 1974 print("\nCompiling user interface files ...")
1941 # step 1: remove old Ui_*.py files 1975 # step 1: remove old Ui_*.py files
1942 for root, _, files in os.walk(sourceDir): 1976 for root, _, files in os.walk(sourceDir):
1943 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]: 1977 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]:
1968 dfile=os.path.join(modDir, "eric6config.py")) 2002 dfile=os.path.join(modDir, "eric6config.py"))
1969 sys.stdout = sys.__stdout__ 2003 sys.stdout = sys.__stdout__
1970 print("\nInstalling eric6 ...") 2004 print("\nInstalling eric6 ...")
1971 res = installEric() 2005 res = installEric()
1972 2006
2007 with open(os.path.join(cfg["ericDir"],
2008 installInfoName), "w") as installInfoFile:
2009 json.dump(installInfo, installInfoFile, indent=2)
2010
1973 # do some cleanup 2011 # do some cleanup
1974 try: 2012 try:
1975 if installFromSource: 2013 if installFromSource:
1976 os.remove(configName) 2014 os.remove(configName)
1977 configNameC = configName + 'c' 2015 configNameC = configName + 'c'

eric ide

mercurial