From d25857a1783b15b185444d38e15805d4c27d96ae Mon Sep 17 00:00:00 2001 From: BrianPetkovsek <16124109+BrianPetkovsek@users.noreply.github.com> Date: Mon, 17 Jun 2019 12:05:06 -0400 Subject: [PATCH] Added uninstall function to setup --- bin/video2x_setup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/video2x_setup.py b/bin/video2x_setup.py index a25fcd6..27f0935 100644 --- a/bin/video2x_setup.py +++ b/bin/video2x_setup.py @@ -89,6 +89,7 @@ class Video2xSetup: def _install_python_requirements(self): """ Read requirements.txt and return its content """ + pip_uninstall('requirements.txt') pip_install('requirements.txt') def _cleanup(self): @@ -203,12 +204,19 @@ def download(url, save_path, chunk_size=4096): def pip_install(file): """ Install python package via python pip module - + pip.main() is not available after pip 9.0.1, thus pip module is not used in this case. """ return subprocess.run([sys.executable, '-m', 'pip', 'install', '-U', '-r', file]).returncode +def pip_uninstall(file): + """ Uninstall python package via python pip module + + pip.main() is not available after pip 9.0.1, thus + pip module is not used in this case. + """ + return subprocess.run([sys.executable, '-m', 'pip', 'uninstall', '-r', file, '-y']).returncode if __name__ == '__main__': try: