Tue, 20 May 2014 19:26:52 +0200
Added the '-y' switch to the install script to allow to install Python2 and Python3 variants of eric5 in parallel by giving the startup script a '_py2' or '_py3' postfix.
--- a/APIs/Python3/eric5.api Sun May 18 19:51:22 2014 +0200 +++ b/APIs/Python3/eric5.api Tue May 20 19:26:52 2014 +0200 @@ -8911,6 +8911,8 @@ eric5.ViewManager.ViewManager.ViewManager.zoomValueChanged?4(value) eric5.ViewManager.ViewManager.ViewManager?1() eric5.ViewManager.factory?4(parent, ui, dbs, pluginManager) +eric5.cleanupSource.cleanupSource?4(dirName) +eric5.cleanupSource.main?4(argv) eric5.compileUiFiles.compileUiDir?4(dir, recurse=False, map=None, **compileUi_args) eric5.compileUiFiles.compileUiFiles?4() eric5.compileUiFiles.compile_ui?4(ui_dir, ui_file) @@ -8979,9 +8981,11 @@ eric5.install-i18n.usage?4(rcode=2) eric5.install.BlackLists?7 eric5.install.PlatformsBlackLists?7 +eric5.install.PythonMarkers?7 eric5.install.apisDir?7 eric5.install.cfg?7 eric5.install.cleanUp?4() +eric5.install.cleanupSource?4(dirName) eric5.install.compileUiDir?4(dir, recurse=False, map=None, **compileUi_args) eric5.install.compileUiFiles?4() eric5.install.compile_ui?4(ui_dir, ui_file) @@ -9001,6 +9005,7 @@ eric5.install.doCompile?7 eric5.install.doDependancyChecks?4() eric5.install.exit?4(rcode=0) +eric5.install.includePythonVariant?7 eric5.install.initGlobals?4() eric5.install.installEric?4() eric5.install.macAppBundleName?7 @@ -9022,7 +9027,9 @@ eric5.patch_modpython.modDir?7 eric5.patch_modpython.progName?7 eric5.patch_modpython.usage?4(rcode=2) +eric5.uninstall.PythonMarkers?7 eric5.uninstall.exit?4(rcode=0) +eric5.uninstall.includePythonVariant?7 eric5.uninstall.initGlobals?4() eric5.uninstall.main?4(argv) eric5.uninstall.progLanguages?7
--- a/Documentation/Help/source.qhp Sun May 18 19:51:22 2014 +0200 +++ b/Documentation/Help/source.qhp Tue May 20 19:26:52 2014 +0200 @@ -1010,6 +1010,7 @@ <section title="eric5.ViewManager.ViewManager" ref="eric5.ViewManager.ViewManager.html" /> <section title="eric5.ViewManager.__init__" ref="eric5.ViewManager.__init__.html" /> </section> + <section title="eric5.cleanupSource" ref="eric5.cleanupSource.html" /> <section title="eric5.compileUiFiles" ref="eric5.compileUiFiles.html" /> <section title="eric5.eric5" ref="eric5.eric5.html" /> <section title="eric5.eric5_api" ref="eric5.eric5_api.html" /> @@ -12859,6 +12860,9 @@ <keyword name="checkBlacklistedVersions" id="checkBlacklistedVersions" ref="eric5.Globals.__init__.html#checkBlacklistedVersions" /> <keyword name="checkPyside" id="checkPyside" ref="eric5.Utilities.__init__.html#checkPyside" /> <keyword name="cleanUp" id="cleanUp" ref="eric5.install.html#cleanUp" /> + <keyword name="cleanupSource" id="cleanupSource" ref="eric5.cleanupSource.html#cleanupSource" /> + <keyword name="cleanupSource" id="cleanupSource" ref="eric5.install.html#cleanupSource" /> + <keyword name="cleanupSource (Module)" id="cleanupSource (Module)" ref="eric5.cleanupSource.html" /> <keyword name="close" id="close" ref="eric5.DebugClients.Ruby.AsyncFile.html#close" /> <keyword name="codeStyleCheck" id="codeStyleCheck" ref="eric5.Plugins.CheckerPlugins.CodeStyleChecker.CodeStyleChecker.html#codeStyleCheck" /> <keyword name="compactPath" id="compactPath" ref="eric5.Utilities.__init__.html#compactPath" /> @@ -13234,6 +13238,7 @@ <keyword name="loadTranslators" id="loadTranslators" ref="eric5.Toolbox.Startup.html#loadTranslators" /> <keyword name="main" id="main" ref="eric5.DataViews.CodeMetrics.html#main" /> <keyword name="main" id="main" ref="eric5.Plugins.WizardPlugins.QRegularExpressionWizard.QRegularExpressionWizardServer.html#main" /> + <keyword name="main" id="main" ref="eric5.cleanupSource.html#main" /> <keyword name="main" id="main" ref="eric5.compileUiFiles.html#main" /> <keyword name="main" id="main" ref="eric5.eric5.html#main" /> <keyword name="main" id="main" ref="eric5.eric5_api.html#main" /> @@ -14280,6 +14285,7 @@ <file>eric5.ViewManager.BookmarkedFilesDialog.html</file> <file>eric5.ViewManager.ViewManager.html</file> <file>eric5.ViewManager.__init__.html</file> + <file>eric5.cleanupSource.html</file> <file>eric5.compileUiFiles.html</file> <file>eric5.eric5.html</file> <file>eric5.eric5_api.html</file>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Documentation/Source/eric5.cleanupSource.html Tue May 20 19:26:52 2014 +0200 @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<html><head> +<title>eric5.cleanupSource</title> +<meta charset="UTF-8"> +<style> +body { + background: #EDECE6; + margin: 0em 1em 10em 1em; + color: black; +} + +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } + +a { color: #BA6D36; } + +</style> +</head> +<body><a NAME="top" ID="top"></a> +<h1>eric5.cleanupSource</h1> +<p> +Script for eric5 to clean up the source tree. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Functions</h3> +<table> +<tr> +<td><a href="#cleanupSource">cleanupSource</a></td> +<td>Cleanup the sources directory to get rid of leftover files and directories.</td> +</tr><tr> +<td><a href="#main">main</a></td> +<td>The main function of the script.</td> +</tr> +</table> +<hr /><hr /> +<a NAME="cleanupSource" ID="cleanupSource"></a> +<h2>cleanupSource</h2> +<b>cleanupSource</b>(<i>dirName</i>) +<p> + Cleanup the sources directory to get rid of leftover files + and directories. +</p><dl> +<dt><i>dirName</i></dt> +<dd> +name of the directory to prune (string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="main" ID="main"></a> +<h2>main</h2> +<b>main</b>(<i>argv</i>) +<p> + The main function of the script. +</p><dl> +<dt><i>argv</i></dt> +<dd> +the list of command line arguments. +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +</body></html> \ No newline at end of file
--- a/Documentation/Source/eric5.install.html Sun May 18 19:51:22 2014 +0200 +++ b/Documentation/Source/eric5.install.html Tue May 20 19:26:52 2014 +0200 @@ -25,7 +25,7 @@ </p> <h3>Global Attributes</h3> <table> -<tr><td>BlackLists</td></tr><tr><td>PlatformsBlackLists</td></tr><tr><td>apisDir</td></tr><tr><td>cfg</td></tr><tr><td>configLength</td></tr><tr><td>configName</td></tr><tr><td>currDir</td></tr><tr><td>defaultMacAppBundleName</td></tr><tr><td>distDir</td></tr><tr><td>doCleanup</td></tr><tr><td>doCompile</td></tr><tr><td>macAppBundleName</td></tr><tr><td>macAppBundlePath</td></tr><tr><td>macPythonExe</td></tr><tr><td>modDir</td></tr><tr><td>platBinDir</td></tr><tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr><tr><td>sourceDir</td></tr> +<tr><td>BlackLists</td></tr><tr><td>PlatformsBlackLists</td></tr><tr><td>PythonMarkers</td></tr><tr><td>apisDir</td></tr><tr><td>cfg</td></tr><tr><td>configLength</td></tr><tr><td>configName</td></tr><tr><td>currDir</td></tr><tr><td>defaultMacAppBundleName</td></tr><tr><td>distDir</td></tr><tr><td>doCleanup</td></tr><tr><td>doCompile</td></tr><tr><td>includePythonVariant</td></tr><tr><td>macAppBundleName</td></tr><tr><td>macAppBundlePath</td></tr><tr><td>macPythonExe</td></tr><tr><td>modDir</td></tr><tr><td>platBinDir</td></tr><tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr><tr><td>sourceDir</td></tr> </table> <h3>Classes</h3> <table> @@ -37,6 +37,9 @@ <td><a href="#cleanUp">cleanUp</a></td> <td>Uninstall the old eric files.</td> </tr><tr> +<td><a href="#cleanupSource">cleanupSource</a></td> +<td>Cleanup the sources directory to get rid of leftover files and directories.</td> +</tr><tr> <td><a href="#compileUiDir">compileUiDir</a></td> <td>Creates Python modules from Qt Designer .ui files in a directory or directory tree.</td> </tr><tr> @@ -104,6 +107,20 @@ </p> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="cleanupSource" ID="cleanupSource"></a> +<h2>cleanupSource</h2> +<b>cleanupSource</b>(<i>dirName</i>) +<p> + Cleanup the sources directory to get rid of leftover files + and directories. +</p><dl> +<dt><i>dirName</i></dt> +<dd> +name of the directory to prune (string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="compileUiDir" ID="compileUiDir"></a> <h2>compileUiDir</h2> <b>compileUiDir</b>(<i>dir, recurse=False, map=None, **compileUi_args</i>)
--- a/Documentation/Source/eric5.uninstall.html Sun May 18 19:51:22 2014 +0200 +++ b/Documentation/Source/eric5.uninstall.html Tue May 20 19:26:52 2014 +0200 @@ -25,7 +25,7 @@ </p> <h3>Global Attributes</h3> <table> -<tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr> +<tr><td>PythonMarkers</td></tr><tr><td>includePythonVariant</td></tr><tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr> </table> <h3>Classes</h3> <table>
--- a/Documentation/Source/index-eric5.html Sun May 18 19:51:22 2014 +0200 +++ b/Documentation/Source/index-eric5.html Tue May 20 19:26:52 2014 +0200 @@ -128,6 +128,9 @@ <h3>Modules</h3> <table> <tr> +<td><a href="eric5.cleanupSource.html">cleanupSource</a></td> +<td>Script for eric5 to clean up the source tree.</td> +</tr><tr> <td><a href="eric5.compileUiFiles.html">compileUiFiles</a></td> <td>Script for eric5 to compile all .ui files to Python source.</td> </tr><tr>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cleanupSource.py Tue May 20 19:26:52 2014 +0200 @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Script for eric5 to clean up the source tree. +""" + +from __future__ import unicode_literals +from __future__ import print_function + +import os +import sys +import fnmatch +import shutil + + +def cleanupSource(dirName): + """ + Cleanup the sources directory to get rid of leftover files + and directories. + + @param dirName name of the directory to prune (string) + """ + # step 1: delete all Ui_*.py files without a corresponding + # *.ui file + dirListing = os.listdir(dirName) + for formName, sourceName in [ + (f.replace('Ui_', "").replace(".py", ".ui"), f) + for f in dirListing if fnmatch.fnmatch(f, "Ui_*.py")]: + if not os.path.exists(os.path.join(dirName, formName)): + os.remove(os.path.join(dirName, sourceName)) + if os.path.exists(os.path.join(dirName, sourceName + "c")): + os.remove(os.path.join(dirName, sourceName + "c")) + + # step 2: delete the __pycache__ directory + if os.path.exists(os.path.join(dirName, "__pycache__")): + shutil.rmtree(os.path.join(dirName, "__pycache__")) + + # step 3: descent into subdirectories and delete them if empty + for name in os.listdir(dirName): + name = os.path.join(dirName, name) + if os.path.isdir(name): + cleanupSource(name) + if len(os.listdir(name)) == 0: + os.rmdir(name) + + +def main(argv): + """ + The main function of the script. + + @param argv the list of command line arguments. + """ + print("Cleaning up source ...") + sourceDir = os.path.dirname(__file__) or "." + cleanupSource(sourceDir) + + +if __name__ == "__main__": + try: + main(sys.argv) + except SystemExit: + raise + except: + print( + "\nAn internal error occured. Please report all the output of the" + " program, \nincluding the following traceback, to" + " eric5-bugs@eric-ide.python-projects.org.\n") + raise
--- a/compileUiFiles.py Sun May 18 19:51:22 2014 +0200 +++ b/compileUiFiles.py Tue May 20 19:26:52 2014 +0200 @@ -9,6 +9,7 @@ """ from __future__ import unicode_literals +from __future__ import print_function import sys import os
--- a/eric5.e4p Sun May 18 19:51:22 2014 +0200 +++ b/eric5.e4p Tue May 20 19:26:52 2014 +0200 @@ -1140,6 +1140,7 @@ <Source>Plugins/VcsPlugins/vcsMercurial/HgBookmarksListDialog.py</Source> <Source>Utilities/mimetypes.py</Source> <Source>Plugins/VcsPlugins/vcsMercurial/HgConflictsListDialog.py</Source> + <Source>cleanupSource.py</Source> </Sources> <Forms> <Form>PyUnit/UnittestDialog.ui</Form>
--- a/install.py Sun May 18 19:51:22 2014 +0200 +++ b/install.py Tue May 20 19:26:52 2014 +0200 @@ -41,6 +41,7 @@ apisDir = None doCleanup = True doCompile = True +includePythonVariant = False cfg = {} progLanguages = ["Python", "Ruby", "QSS"] sourceDir = "eric" @@ -77,6 +78,12 @@ }, } +# Define file name markers for Python variants +PythonMarkers = { + 2: "_py2", + 3: "_py3", +} + def exit(rcode=0): """ @@ -110,13 +117,13 @@ print() print("Usage:") if sys.platform == "darwin": - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" + print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" " [-m name] [-p python]".format(progName)) elif sys.platform.startswith("win"): - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" + print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]" .format(progName)) else: - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" + print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" .format(progName)) print("where:") print(" -h display this help message") @@ -142,9 +149,10 @@ print(" (default: {0}".format(macAppBundlePath)) print(" -p python name of the python executable") print(" (default: {0})".format(macPythonExe)) + print(" -c don't cleanup old installation first") print(" -x don't perform dependency checks (use on your own" " risk)") - print(" -c don't cleanup old installation first") + print(" -y add the Python variant to the executable names") print(" -z don't compile the installed python files") print() print("The file given to the -f option must be valid Python code" @@ -351,9 +359,9 @@ # step 1: delete all Ui_*.py files without a corresponding # *.ui file dirListing = os.listdir(dirName) - for formName, sourceName in [(f.replace('Ui_',"").replace(".py",".ui"), f) - for f in dirListing - if fnmatch.fnmatch(f, "Ui_*.py")]: + for formName, sourceName in [ + (f.replace('Ui_', "").replace(".py", ".ui"), f) + for f in dirListing if fnmatch.fnmatch(f, "Ui_*.py")]: if not os.path.exists(os.path.join(dirName, formName)): os.remove(os.path.join(dirName, sourceName)) if os.path.exists(os.path.join(dirName, sourceName + "c")): @@ -376,7 +384,7 @@ """ Uninstall the old eric files. """ - global macAppBundleName, macAppBundlePath, platBinDir + global macAppBundleName, macAppBundlePath, platBinDir, includePythonVariant try: from eric5config import getConfig @@ -407,6 +415,8 @@ "eric5-plugininstall", "eric5-pluginuninstall", "eric5-pluginrepository", "eric5-sqlbrowser", "eric5-webbrowser", "eric5-iconeditor", + ] + rem_wnames2 = [ "eric5_api", "eric5_compare", "eric5_configure", "eric5_diff", "eric5_doc", "eric5_qregularexpression", @@ -419,6 +429,11 @@ "eric5_webbrowser", "eric5_iconeditor", "eric5_snap", ] + if includePythonVariant: + marker = PythonMarkers[sys.version_info.major] + rem_wnames.extend([n + marker for n in rem_wnames2]) + else: + rem_wnames.extend(rem_wnames2) try: for rem_wname in rem_wnames: @@ -480,7 +495,6 @@ bundlePath = os.path.join(macAppBundlePath, macAppBundleName) if os.path.exists(bundlePath): shutil.rmtree(bundlePath) - except (IOError, OSError) as msg: sys.stderr.write( 'Error: {0}\nTry install with admin rights.\n'.format(msg)) @@ -508,30 +522,58 @@ @return result code (integer) """ global distDir, doCleanup, cfg, progLanguages, sourceDir, configName + global includePythonVariant # Create the platform specific wrappers. wnames = [] - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_api", False)) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_compare")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_configure")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_diff")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_doc", False)) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_editor")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_iconeditor")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_plugininstall")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_pluginrepository")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_pluginuninstall")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_qregexp")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_qregularexpression")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_re")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_snap")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_sqlbrowser")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_tray")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_trpreviewer")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_uipreviewer")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_unittest")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5_webbrowser")) - wnames.append(createPyWrapper(cfg['ericDir'], "eric5")) + if includePythonVariant: + marker = PythonMarkers[sys.version_info.major] + else: + marker = "" + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_api" + marker, + False)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_compare" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_configure" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_diff" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_doc" + marker, + False)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_editor" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_iconeditor" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_plugininstall" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_pluginrepository" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_pluginuninstall" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_qregexp" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_qregularexpression" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_re" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_snap" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_sqlbrowser" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_tray" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_trpreviewer" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_uipreviewer" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_unittest" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5_webbrowser" + marker)) + wnames.append(createPyWrapper(cfg['ericDir'], + "eric5" + marker)) # set install prefix, if not None if distDir: @@ -1135,7 +1177,7 @@ # Parse the command line. global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir - global sourceDir, configName + global sourceDir, configName, includePythonVariant global macAppBundlePath, macAppBundleName, macPythonExe if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9): @@ -1152,11 +1194,11 @@ try: if sys.platform.startswith("win"): - optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:") + optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:") elif sys.platform == "darwin": - optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:m:n:p:") + optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:m:n:p:") else: - optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:") + optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:") except getopt.GetoptError: usage() @@ -1181,6 +1223,8 @@ doCleanup = False elif opt == "-z": doCompile = False + elif opt == "-y": + includePythonVariant = True elif opt == "-f": try: exec(compile(open(arg).read(), arg, 'exec'), globals())
--- a/uninstall.py Sun May 18 19:51:22 2014 +0200 +++ b/uninstall.py Tue May 20 19:26:52 2014 +0200 @@ -26,6 +26,13 @@ progName = None pyModDir = None progLanguages = ["Python", "Ruby", "QSS"] +includePythonVariant = False + +# Define file name markers for Python variants +PythonMarkers = { + 2: "_py2", + 3: "_py3", +} def exit(rcode=0): @@ -53,6 +60,7 @@ print(" {0} [-h]".format(progName)) print("where:") print(" -h display this help message") + print(" -y remove executables with Python variant in name") exit(rcode) @@ -109,6 +117,8 @@ "eric5-plugininstall", "eric5-pluginuninstall", "eric5-pluginrepository", "eric5-sqlbrowser", "eric5-webbrowser", "eric5-iconeditor", + ] + rem_wnames2 = [ "eric5_api", "eric5_compare", "eric5_configure", "eric5_diff", "eric5_doc", "eric5_qregularexpression", @@ -121,62 +131,73 @@ "eric5_webbrowser", "eric5_iconeditor", "eric5_snap", ] - for rem_wname in rem_wnames: - rwname = wrapperName(getConfig('bindir'), rem_wname) - if os.path.exists(rwname): - os.remove(rwname) - - # Cleanup our config file(s) - for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']: - e5cfile = os.path.join(pyModDir, name) - if os.path.exists(e5cfile): - os.remove(e5cfile) - e5cfile = os.path.join(pyModDir, "__pycache__", name) - path, ext = os.path.splitext(e5cfile) - for f in glob.glob("{0}.*{1}".format(path, ext)): - os.remove(f) - - # Cleanup the install directories - for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', - 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', - 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', - 'ericDir']: - dirpath = getConfig(name) - if os.path.exists(dirpath): - shutil.rmtree(dirpath, True) + if includePythonVariant: + marker = PythonMarkers[sys.version_info.major] + rem_wnames.extend([n + marker for n in rem_wnames2]) + else: + rem_wnames.extend(rem_wnames2) - # Cleanup translations - for name in glob.glob( - os.path.join(getConfig('ericTranslationsDir'), 'eric5_*.qm')): - if os.path.exists(name): - os.remove(name) - - # Cleanup API files - apidir = getConfig('apidir') - for progLanguage in progLanguages: - for name in getConfig('apis'): - apiname = os.path.join(apidir, progLanguage.lower(), name) - if os.path.exists(apiname): + try: + for rem_wname in rem_wnames: + rwname = wrapperName(getConfig('bindir'), rem_wname) + if os.path.exists(rwname): + os.remove(rwname) + + # Cleanup our config file(s) + for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']: + e5cfile = os.path.join(pyModDir, name) + if os.path.exists(e5cfile): + os.remove(e5cfile) + e5cfile = os.path.join(pyModDir, "__pycache__", name) + path, ext = os.path.splitext(e5cfile) + for f in glob.glob("{0}.*{1}".format(path, ext)): + os.remove(f) + + # Cleanup the install directories + for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', + 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', + 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', + 'ericDir']: + dirpath = getConfig(name) + if os.path.exists(dirpath): + shutil.rmtree(dirpath, True) + + # Cleanup translations + for name in glob.glob( + os.path.join(getConfig('ericTranslationsDir'), 'eric5_*.qm')): + if os.path.exists(name): + os.remove(name) + + # Cleanup API files + apidir = getConfig('apidir') + for progLanguage in progLanguages: + for name in getConfig('apis'): + apiname = os.path.join(apidir, progLanguage.lower(), name) + if os.path.exists(apiname): + os.remove(apiname) + for apiname in glob.glob( + os.path.join(apidir, progLanguage.lower(), "*.bas")): os.remove(apiname) - for apiname in glob.glob( - os.path.join(apidir, progLanguage.lower(), "*.bas")): - os.remove(apiname) - - if sys.platform == "darwin": - # delete the Mac app bundle - if os.path.exists("/Developer/Applications/Eric5"): - shutil.rmtree("/Developer/Applications/Eric5") - try: - macAppBundlePath = getConfig("macAppBundlePath") - macAppBundleName = getConfig("macAppBundleName") - except AttributeError: - macAppBundlePath = "/Applications" - macAppBundleName = "eric5.app" - if os.path.exists("/Applications/" + macAppBundleName): - shutil.rmtree("/Applications/" + macAppBundleName) - bundlePath = os.path.join(macAppBundlePath, macAppBundleName) - if os.path.exists(bundlePath): - shutil.rmtree(bundlePath) + + if sys.platform == "darwin": + # delete the Mac app bundle + if os.path.exists("/Developer/Applications/Eric5"): + shutil.rmtree("/Developer/Applications/Eric5") + try: + macAppBundlePath = getConfig("macAppBundlePath") + macAppBundleName = getConfig("macAppBundleName") + except AttributeError: + macAppBundlePath = "/Applications" + macAppBundleName = "eric5.app" + if os.path.exists("/Applications/" + macAppBundleName): + shutil.rmtree("/Applications/" + macAppBundleName) + bundlePath = os.path.join(macAppBundlePath, macAppBundleName) + if os.path.exists(bundlePath): + shutil.rmtree(bundlePath) + except (IOError, OSError) as msg: + sys.stderr.write( + 'Error: {0}\nTry uninstall with admin rights.\n'.format(msg)) + exit(7) def main(argv): @@ -187,6 +208,8 @@ """ import getopt + global includePythonVariant + initGlobals() # Parse the command line. @@ -194,7 +217,7 @@ progName = os.path.basename(argv[0]) try: - optlist, args = getopt.getopt(argv[1:], "h") + optlist, args = getopt.getopt(argv[1:], "hy") except getopt.GetoptError: usage() @@ -203,6 +226,8 @@ for opt, arg in optlist: if opt == "-h": usage(0) + if opt == "-y": + includePythonVariant = True try: uninstallEric()