summaryrefslogtreecommitdiff
path: root/tools/pipremove
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-03-23 13:51:17 -0600
committerChad Smith <chad.smith@canonical.com>2018-03-23 13:51:17 -0600
commit68d798bb793052f589a7e48c508aca9031c7e271 (patch)
treec40e681e776741218685eecb5de9d419883ae90a /tools/pipremove
parent0c2f1ea29abc88957d21f56d432649989a8e4dfd (diff)
downloadvyos-cloud-init-68d798bb793052f589a7e48c508aca9031c7e271.tar.gz
vyos-cloud-init-68d798bb793052f589a7e48c508aca9031c7e271.zip
tests: remove jsonschema from xenial tox environment.
Ubuntu 16.04 (xenial) does not have jsonschema installed by default. As it is listed in requirements, the tox environment will always have it installed. Add the helper tools/pipremove that removes pip packages. Then use that to remove jsonschema without noise of always running and ignoring a 'pip uninstall jsonschema'.
Diffstat (limited to 'tools/pipremove')
-rwxr-xr-xtools/pipremove14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/pipremove b/tools/pipremove
new file mode 100755
index 00000000..f8f4ff11
--- /dev/null
+++ b/tools/pipremove
@@ -0,0 +1,14 @@
+#!/usr/bin/python3
+import subprocess
+import sys
+
+for pkg in sys.argv[1:]:
+ try:
+ exec('import %s' % pkg) # pylint: disable=W0122
+ except ImportError:
+ continue
+ sys.stderr.write("%s removing package %s\n" % (sys.argv[0], pkg))
+ ret = subprocess.Popen(['pip', 'uninstall', '--yes', pkg]).wait()
+ if ret != 0:
+ sys.stderr.write("Failed to uninstall %s (%d)\n" % (pkg, ret))
+ sys.exit(ret)