install.py

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

eric ide

mercurial