From a1b0c97bb06203fd153404aade5746e526fb8340 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Mon, 23 Jan 2017 17:04:12 +0900 Subject: [PATCH 1/2] Add uninstall sub-command --- cudnnenv/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/cudnnenv/__init__.py b/cudnnenv/__init__.py index ec7e397..13411a2 100644 --- a/cudnnenv/__init__.py +++ b/cudnnenv/__init__.py @@ -134,10 +134,33 @@ def select_cudnn(ver): os.symlink(version_path, symlink_path) +def yes_no_query(question): + while True: + user_input = raw_input('%s [y/n] ' % question).lower() + if user_input == 'y': + return True + elif user_input == 'n': + return False + + +def uninstall_cudnn(ver): + path = get_version_path(ver) + if not os.path.exists(path): + print('version %s is not installed' % ver) + sys.exit(2) + + if yes_no_query('remove %s?' % path): + shutil.rmtree(path, ignore_errors=True) + + def install(args): select_cudnn(args.version) +def uninstall(args): + uninstall_cudnn(args.version) + + def get_version(): symlink_path = get_active_path() if os.path.islink(symlink_path): @@ -181,6 +204,12 @@ def main(): 'Select from [%s]' % ', '.join(vers)) sub.set_defaults(func=install) + sub = subparsers.add_parser('uninstall', help='Uninstall version') + sub.add_argument( + 'version', metavar='VERSION', + help='Version of cuDNN you want to uninstall.') + sub.set_defaults(func=uninstall) + sub = subparsers.add_parser('version', help='Show active version') sub.set_defaults(func=version) From 4b84e3d2db773b18de5a4284ecbe0a3bbad401d5 Mon Sep 17 00:00:00 2001 From: Yuya Unno Date: Mon, 23 Jan 2017 17:07:53 +0900 Subject: [PATCH 2/2] Update readme --- README.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.rst b/README.rst index 547ebf4..a924313 100644 --- a/README.rst +++ b/README.rst @@ -34,6 +34,7 @@ positional arguments: {install,version,versions,deactivate} :`install`: Install version +:`uninstall`: Uninstall version :`version`: Show active version :`versions`: Show avalable versions :`deactivate`: Deactivate cudnnenv @@ -57,6 +58,20 @@ positional arguments: :`VERSION`: Version of cuDNN you want to install and activate. Select from [v2, v3, v4, v5, v5-cuda8, v51, v51-cuda8] +`uninstall` +~~~~~~~~~~~ + +`uninstall` subcommand uninstalls a given version of cuDNN from your environment. + +:: + + usage: cudnnenv uninstall [-h] VERSION + +positional arguments: + +:VERSION: Version of cuDNN you want to uninstall. + + `version` ~~~~~~~~~