Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uninstall sub-command #10

Merged
merged 2 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
~~~~~~~~~

Expand Down
29 changes: 29 additions & 0 deletions cudnnenv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down