From c8ea736eb3ac25f654b096e8987133ba8b470f5f Mon Sep 17 00:00:00 2001 From: Noah Beard Date: Thu, 4 May 2023 14:15:52 -0400 Subject: [PATCH] Use shell.exec instead of builder.script --- .builder/actions/aws_crt_python.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.builder/actions/aws_crt_python.py b/.builder/actions/aws_crt_python.py index 4df622b13..0e7e97eea 100644 --- a/.builder/actions/aws_crt_python.py +++ b/.builder/actions/aws_crt_python.py @@ -17,16 +17,16 @@ class AWSCrtPython(Builder.Action): # As of writing, this is primarily an issue with the AL2-x64 image. def try_to_upgrade_pip(self, env): did_upgrade = False - try: - Builder.Script(commands=[[self.python, '-m', 'pip', 'install', - '--upgrade', 'pip']], exit_on_fail=False).run(env) + + pip_result = env.shell.exec(self.python, '-m', 'pip', 'install', '--upgrade', 'pip', Check=False) + if pip_result.returncode == 0: did_upgrade = True - except Exception: + else: print("Could not update pip via normal pip upgrade. Next trying via package manager...") if (did_upgrade == False): try: - Builder.Script(commands=[Builder.InstallPackages(['pip'],)], exit_on_fail=False).run(env) + Builder.InstallPackages(['pip']).run(env) did_upgrade = True except Exception: print("Could not update pip via package manager. Next resorting to forcing an ignore install...") @@ -35,13 +35,14 @@ def try_to_upgrade_pip(self, env): # Only run in GitHub actions by checking for specific environment variable # Source: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables if (os.getenv("GITHUB_ACTIONS") is not None): - try: - Builder.Script(commands=[[self.python, '-m', 'pip', 'install', '--upgrade', - '--ignore-installed', 'pip']], exit_on_fail=False).run(env) - except Exception as ex: + pip_result = env.shell.exec( + self.python, '-m', 'pip', 'install', '--upgrade', + '--ignore-installed', 'pip', Check=False) + if pip_result.returncode == 0: + did_upgrade = True + else: print("Could not update pip via ignore install! Something is terribly wrong!") sys.exit(12) - did_upgrade = True else: print("Not on GitHub actions - skipping reinstalling Pip. Update/Install pip manually and rerun the builder")