320 for f in glob.glob("{0}.*{1}".format(path, ext)): |
320 for f in glob.glob("{0}.*{1}".format(path, ext)): |
321 os.remove(f) |
321 os.remove(f) |
322 |
322 |
323 # Cleanup the install directories |
323 # Cleanup the install directories |
324 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', |
324 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', |
325 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 'ericCodeTemplatesDir', |
325 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', |
326 'ericOthersDir', 'ericStylesDir', 'ericDir']: |
326 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir']: |
327 if os.path.exists(getConfig(name)): |
327 if os.path.exists(getConfig(name)): |
328 shutil.rmtree(getConfig(name), True) |
328 shutil.rmtree(getConfig(name), True) |
329 |
329 |
330 # Cleanup translations |
330 # Cleanup translations |
331 for name in glob.glob(os.path.join(getConfig('ericTranslationsDir'), 'eric5_*.qm')): |
331 for name in glob.glob( |
|
332 os.path.join(getConfig('ericTranslationsDir'),'eric5_*.qm')): |
332 if os.path.exists(name): |
333 if os.path.exists(name): |
333 os.remove(name) |
334 os.remove(name) |
334 |
335 |
335 # Cleanup API files |
336 # Cleanup API files |
336 try: |
337 try: |
338 for progLanguage in progLanguages: |
339 for progLanguage in progLanguages: |
339 for name in getConfig('apis'): |
340 for name in getConfig('apis'): |
340 apiname = os.path.join(apidir, progLanguage.lower(), name) |
341 apiname = os.path.join(apidir, progLanguage.lower(), name) |
341 if os.path.exists(apiname): |
342 if os.path.exists(apiname): |
342 os.remove(apiname) |
343 os.remove(apiname) |
343 for apiname in glob.glob(os.path.join(apidir, progLanguage.lower(), "*.bas")): |
344 for apiname in glob.glob( |
|
345 os.path.join(apidir, progLanguage.lower(), "*.bas")): |
344 os.remove(apiname) |
346 os.remove(apiname) |
345 except AttributeError: |
347 except AttributeError: |
346 pass |
348 pass |
|
349 |
|
350 if sys.platform == "darwin": |
|
351 # delete the Mac app bundle |
|
352 if os.path.exists("/Developer/Applications/Eric5"): |
|
353 shutil.rmtree("/Developer/Applications/Eric5") |
347 |
354 |
348 except IOError as msg: |
355 except IOError as msg: |
349 sys.stderr.write('IOError: {0}\nTry install with admin rights.\n'.format(msg)) |
356 sys.stderr.write('IOError: {0}\nTry install with admin rights.\n'.format(msg)) |
350 exit(7) |
357 exit(7) |
351 |
358 |
516 else: |
523 else: |
517 shutil.copy(os.path.join(sourceDir, "icons", "default", "eric.png"), |
524 shutil.copy(os.path.join(sourceDir, "icons", "default", "eric.png"), |
518 "/usr/share/pixmaps") |
525 "/usr/share/pixmaps") |
519 shutil.copy(os.path.join(sourceDir, "eric5.desktop"), |
526 shutil.copy(os.path.join(sourceDir, "eric5.desktop"), |
520 "/usr/share/applications") |
527 "/usr/share/applications") |
|
528 |
|
529 # Create a Mac application bundle |
|
530 if sys.platform == "darwin": |
|
531 createMacAppBundle(cfg['ericDir']) |
|
532 |
|
533 |
|
534 def createMacAppBundle(pydir): |
|
535 """ |
|
536 Create a Mac application bundle. |
|
537 |
|
538 @param pydir the name of the directory where the Python script will eventually |
|
539 be installed (string) |
|
540 """ |
|
541 global cfg, sourceDir |
|
542 |
|
543 dirs = {"contents": "/Developer/Applications/Eric5/eric5.app/Contents/", |
|
544 "exe": "/Developer/Applications/Eric5/eric5.app/Contents/MacOS", |
|
545 "icns": "/Developer/Applications/Eric5/eric5.app/Contents/Resources"} |
|
546 os.makedirs(dirs["contents"]) |
|
547 os.mkdir(dirs["exe"]) |
|
548 os.mkdir(dirs["icns"]) |
|
549 |
|
550 wname = os.path.join(dirs["exe"], "eric5") |
|
551 path = os.getenv("PATH", "") |
|
552 if path: |
|
553 pybin = os.path.join(sys.exec_prefix, "bin") |
|
554 pathlist = path.split(os.pathsep) |
|
555 if pybin not in pathlist: |
|
556 pathlist.insert(0, pybin) |
|
557 path = os.pathsep.join(pathlist) |
|
558 wrapper = \ |
|
559 '''#!/bin/sh |
|
560 |
|
561 PATH={0} |
|
562 exec "{1}/bin/pythonw3" "{2}/{3}.py" "$@" |
|
563 '''.format(path, sys.exec_prefix, pydir, "eric5") |
|
564 else: |
|
565 wrapper = \ |
|
566 '''#!/bin/sh |
|
567 |
|
568 exec "{0}/bin/pythonw3" "{1}/{2}.py" "$@" |
|
569 '''.format(sys.exec_prefix, pydir, "eric5") |
|
570 copyToFile(wname, wrapper) |
|
571 os.chmod(wname, 0o755) |
|
572 |
|
573 shutil.copy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"), |
|
574 os.path.join(dirs["icns"], "eric.icns")) |
|
575 |
|
576 copyToFile(os.path.join(dirs["contents"], "Info.plist"), |
|
577 '''<?xml version="1.0" encoding="UTF-8"?> |
|
578 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" |
|
579 "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
|
580 <plist version="1.0"> |
|
581 <dict> |
|
582 <key>CFBundleExecutable</key> |
|
583 <string>eric5</string> |
|
584 <key>CFBundleIconFile</key> |
|
585 <string>eric.icns</string> |
|
586 <key>CFBundleInfoDictionaryVersion</key> |
|
587 <string>1.0</string> |
|
588 <key>CFBundleName</key> |
|
589 <string>eric5</string> |
|
590 <key>CFBundlePackageType</key> |
|
591 <string>APPL</string> |
|
592 <key>CFBundleSignature</key> |
|
593 <string>????</string> |
|
594 <key>CFBundleVersion</key> |
|
595 <string>1.0</string> |
|
596 </dict> |
|
597 </plist> |
|
598 ''' |
|
599 ) |
521 |
600 |
522 |
601 |
523 def createInstallConfig(): |
602 def createInstallConfig(): |
524 """ |
603 """ |
525 Create the installation config dictionary. |
604 Create the installation config dictionary. |