Skip to content

Commit

Permalink
Use shell.exec instead of builder.script
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTwigleg committed May 4, 2023
1 parent 8d00645 commit c8ea736
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .builder/actions/aws_crt_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand All @@ -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")

Expand Down

0 comments on commit c8ea736

Please sign in to comment.