install.py

branch
5_2_x
changeset 2161
32591cea4dba
parent 2146
f42f336525dd
child 2178
fd00606ce958
equal deleted inserted replaced
2159:7ab512c23fdd 2161:32591cea4dba
256 for filter in filters: 256 for filter in filters:
257 if fnmatch.fnmatch(srcname, filter): 257 if fnmatch.fnmatch(srcname, filter):
258 if not os.path.isdir(dst): 258 if not os.path.isdir(dst):
259 os.makedirs(dst) 259 os.makedirs(dst)
260 shutil.copy2(srcname, dstname) 260 shutil.copy2(srcname, dstname)
261 os.chmod(dstname, 0o644)
261 break 262 break
262 else: 263 else:
263 if os.path.isdir(srcname) and not srcname in excludeDirs: 264 if os.path.isdir(srcname) and not srcname in excludeDirs:
264 copyTree(srcname, dstname, filters, excludePatterns=excludePatterns) 265 copyTree(srcname, dstname, filters, excludePatterns=excludePatterns)
265 266
283 Package containing the global plugins. 284 Package containing the global plugins.
284 """ 285 """
285 ''' 286 '''
286 ) 287 )
287 f.close() 288 f.close()
289 os.chmod(fname, 0o644)
288 290
289 291
290 def cleanUp(): 292 def cleanUp():
291 """ 293 """
292 Uninstall the old eric files. 294 Uninstall the old eric files.
387 except OSError as msg: 389 except OSError as msg:
388 sys.stderr.write('OSError: {0}\nTry install with admin rights.\n'.format(msg)) 390 sys.stderr.write('OSError: {0}\nTry install with admin rights.\n'.format(msg))
389 exit(7) 391 exit(7)
390 392
391 393
394 def shutilCopy(src, dst):
395 """
396 Wrapper function around shutil.copy() to ensure the permissions.
397
398 @param src source file name (string)
399 @param dst destination file name or directory name (string)
400 """
401 shutil.copy(src, dst)
402 if os.path.isdir(dst):
403 dst = os.path.join(dst, os.path.basename(src))
404 os.chmod(dst, 0o644)
405
406
392 def installEric(): 407 def installEric():
393 """ 408 """
394 Actually perform the installation steps. 409 Actually perform the installation steps.
395 """ 410 """
396 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName 411 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
429 if not os.path.isdir(cfg[key]): 444 if not os.path.isdir(cfg[key]):
430 os.makedirs(cfg[key]) 445 os.makedirs(cfg[key])
431 446
432 # copy the eric5 config file 447 # copy the eric5 config file
433 if distDir: 448 if distDir:
434 shutil.copy(configName, cfg['mdir']) 449 shutilCopy(configName, cfg['mdir'])
435 if os.path.exists(configName + 'c'): 450 if os.path.exists(configName + 'c'):
436 shutil.copy(configName + 'c', cfg['mdir']) 451 shutilCopy(configName + 'c', cfg['mdir'])
437 else: 452 else:
438 shutil.copy(configName, modDir) 453 shutilCopy(configName, modDir)
439 if os.path.exists(configName + 'c'): 454 if os.path.exists(configName + 'c'):
440 shutil.copy(configName + 'c', modDir) 455 shutilCopy(configName + 'c', modDir)
441 456
442 # copy the various parts of eric5 457 # copy the various parts of eric5
443 copyTree(sourceDir, cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'], 458 copyTree(sourceDir, cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'],
444 ['{1}{0}Examples'.format(os.sep, sourceDir)], 459 ['{1}{0}Examples'.format(os.sep, sourceDir)],
445 excludePatterns=["eric5config.py*"]) 460 excludePatterns=["eric5config.py*"])
471 copyTree('{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'], 486 copyTree('{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'],
472 ['*.py', '*.pyc', '*.pyo']) 487 ['*.py', '*.pyc', '*.pyo'])
473 488
474 # copy the wrappers 489 # copy the wrappers
475 for wname in wnames: 490 for wname in wnames:
476 shutil.copy(wname, cfg['bindir']) 491 shutilCopy(wname, cfg['bindir'])
477 os.remove(wname) 492 os.remove(wname)
478 493
479 # copy the license file 494 # copy the license file
480 shutil.copy('{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir']) 495 shutilCopy('{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir'])
481 496
482 # create the global plugins directory 497 # create the global plugins directory
483 createGlobalPluginsDir() 498 createGlobalPluginsDir()
484 499
485 except IOError as msg: 500 except IOError as msg:
491 exit(7) 506 exit(7)
492 507
493 # copy some text files to the doc area 508 # copy some text files to the doc area
494 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: 509 for name in ["LICENSE.GPL3", "THANKS", "changelog"]:
495 try: 510 try:
496 shutil.copy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir']) 511 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir'])
497 except EnvironmentError: 512 except EnvironmentError:
498 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 513 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir))
499 for name in glob.glob(os.path.join(sourceDir, 'README*.*')): 514 for name in glob.glob(os.path.join(sourceDir, 'README*.*')):
500 try: 515 try:
501 shutil.copy(name, cfg['ericDocDir']) 516 shutilCopy(name, cfg['ericDocDir'])
502 except EnvironmentError: 517 except EnvironmentError:
503 print("Could not install '{1}'.".format(name)) 518 print("Could not install '{1}'.".format(name))
504 519
505 # copy some more stuff 520 # copy some more stuff
506 for name in ['default.e4k', 'default_Mac.e4k']: 521 for name in ['default.e4k', 'default_Mac.e4k']:
507 try: 522 try:
508 shutil.copy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericOthersDir']) 523 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericOthersDir'])
509 except EnvironmentError: 524 except EnvironmentError:
510 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 525 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir))
511 526
512 # install the API file 527 # install the API file
513 for progLanguage in progLanguages: 528 for progLanguage in progLanguages:
514 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) 529 apidir = os.path.join(cfg['apidir'], progLanguage.lower())
515 if not os.path.exists(apidir): 530 if not os.path.exists(apidir):
516 os.makedirs(apidir) 531 os.makedirs(apidir)
517 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 532 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")):
518 try: 533 try:
519 shutil.copy(apiName, apidir) 534 shutilCopy(apiName, apidir)
520 except EnvironmentError: 535 except EnvironmentError:
521 print("Could not install '{0}'.".format(apiName)) 536 print("Could not install '{0}'.".format(apiName))
522 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.bas")): 537 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.bas")):
523 try: 538 try:
524 shutil.copy(apiName, apidir) 539 shutilCopy(apiName, apidir)
525 except EnvironmentError: 540 except EnvironmentError:
526 print("Could not install '{0}'.".format(apiName)) 541 print("Could not install '{0}'.".format(apiName))
527 if progLanguage == "Python": 542 if progLanguage == "Python":
528 # copy Python3 API files to the same destination 543 # copy Python3 API files to the same destination
529 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")): 544 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")):
530 try: 545 try:
531 shutil.copy(apiName, apidir) 546 shutilCopy(apiName, apidir)
532 except EnvironmentError: 547 except EnvironmentError:
533 print("Could not install '{0}'.".format(apiName)) 548 print("Could not install '{0}'.".format(apiName))
534 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.bas")): 549 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.bas")):
535 try: 550 try:
536 shutil.copy(apiName, apidir) 551 shutilCopy(apiName, apidir)
537 except EnvironmentError: 552 except EnvironmentError:
538 print("Could not install '{0}'.".format(apiName)) 553 print("Could not install '{0}'.".format(apiName))
539 554
540 # create menu entry for Linux systems 555 # create menu entry for Linux systems
541 if sys.platform.startswith("linux"): 556 if sys.platform.startswith("linux"):
542 if distDir: 557 if distDir:
543 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) 558 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
544 if not os.path.exists(dst): 559 if not os.path.exists(dst):
545 os.makedirs(dst) 560 os.makedirs(dst)
546 shutil.copy(os.path.join(sourceDir, "icons", "default", "eric_2.png"), 561 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric_2.png"),
547 os.path.join(dst, "eric.png")) 562 os.path.join(dst, "eric.png"))
548 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications")) 563 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications"))
549 if not os.path.exists(dst): 564 if not os.path.exists(dst):
550 os.makedirs(dst) 565 os.makedirs(dst)
551 shutil.copy(os.path.join(sourceDir, "eric5.desktop"), dst) 566 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
552 else: 567 else:
553 shutil.copy(os.path.join(sourceDir, "icons", "default", "eric_2.png"), 568 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric_2.png"),
554 "/usr/share/pixmaps/eric.png") 569 "/usr/share/pixmaps/eric.png")
555 shutil.copy(os.path.join(sourceDir, "eric5.desktop"), 570 shutilCopy(os.path.join(sourceDir, "eric5.desktop"),
556 "/usr/share/applications") 571 "/usr/share/applications")
557 572
558 # Create a Mac application bundle 573 # Create a Mac application bundle
559 if sys.platform == "darwin": 574 if sys.platform == "darwin":
560 createMacAppBundle(cfg['ericDir']) 575 createMacAppBundle(cfg['ericDir'])
602 exec "{0}" "{1}/{2}.py" "$@" 617 exec "{0}" "{1}/{2}.py" "$@"
603 '''.format(starter, pydir, "eric5") 618 '''.format(starter, pydir, "eric5")
604 copyToFile(wname, wrapper) 619 copyToFile(wname, wrapper)
605 os.chmod(wname, 0o755) 620 os.chmod(wname, 0o755)
606 621
607 shutil.copy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"), 622 shutilCopy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"),
608 os.path.join(dirs["icns"], "eric.icns")) 623 os.path.join(dirs["icns"], "eric.icns"))
609 624
610 copyToFile(os.path.join(dirs["contents"], "Info.plist"), 625 copyToFile(os.path.join(dirs["contents"], "Info.plist"),
611 '''<?xml version="1.0" encoding="UTF-8"?> 626 '''<?xml version="1.0" encoding="UTF-8"?>
612 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 627 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
613 "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 628 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

eric ide

mercurial