Skip to content

Commit

Permalink
Validate python intepreters before calling them.
Browse files Browse the repository at this point in the history
Travis made us stumble here. They seem to inject pseudo-interpreters
into the runtime so that we find python3.7 just to trigger a script
that says 'no python 3.7 is installed here'. Glorius.
  • Loading branch information
ctheune committed Sep 28, 2020
1 parent c0c23a7 commit dfa3625
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/appenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ def ensure_newest_python():
if python == current_python:
# found best python and we're already running as it
break
# Try whether this Python works
try:
subprocess.check_call(
[python, "-c", "print(1)"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
except subprocess.CalledProcessError:
continue
argv = [os.path.basename(python)] + sys.argv
os.environ["APPENV_NEWEST_PYTHON"] = python
os.execv(python, argv)
Expand Down

0 comments on commit dfa3625

Please sign in to comment.