From b5b2b1f27fcc672c47db353c335155d63bc2082e Mon Sep 17 00:00:00 2001 From: kipje13 <13234441+kipje13@users.noreply.github.com> Date: Thu, 26 Dec 2019 19:53:49 +0100 Subject: [PATCH] Call pip with the subprocess module. --- run.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/run.py b/run.py index 60af312..6a223de 100644 --- a/run.py +++ b/run.py @@ -1,16 +1,6 @@ +import subprocess import sys -# https://stackoverflow.com/a/51704613 -try: - from pip import main as pipmain -except ImportError: - from pip._internal import main as pipmain - -# More pip changes breaking us. -main_fn = pipmain -if hasattr(pipmain, 'main'): - main_fn = pipmain.main - DEFAULT_LOGGER = 'rlbot' if __name__ == '__main__': @@ -23,7 +13,7 @@ logger.log(logging_utils.logging_level, 'Skipping upgrade check for now since it looks like you have no internet') elif public_utils.is_safe_to_upgrade(): - main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) + subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) # https://stackoverflow.com/a/44401013 rlbots = [module for module in sys.modules if module.startswith('rlbot')] @@ -31,7 +21,7 @@ sys.modules.pop(rlbot_module) except ImportError: - main_fn(['install', '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) + subprocess.call([sys.executable, "-m", "pip", "install", '-r', 'requirements.txt', '--upgrade', '--upgrade-strategy=eager']) try: if len(sys.argv) > 1 and sys.argv[1] == 'gui':