Commit 48cd818b authored by Sajjad Mirza's avatar Sajjad Mirza Committed by Commit Bot

Reland "[mb.py] Check multiple locations for the real python."

This is a reland of 2131f972

Original change's description:
> [mb.py] Check multiple locations for the real python.
>
> Sometimes the value of sys.prefix (or sys.real_prefix in vpython)
> includes the bin/ directory within the python installation, and
> sometimes it does not. To accommodate this, check both prefix/bin and
> prefix itself for the python executable.
>
> Bug: 1049421
> Change-Id: Ia7c072dc0b4b8232ec8fdce20f9211e3c978a3ad
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055976
> Commit-Queue: Sajjad Mirza <sajjadm@chromium.org>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#741574}

Bug: 1049421
Change-Id: Ib0d83fa1b6613e62334336cf567d9c311dba2cfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2067291Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Sajjad Mirza <sajjadm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743383}
parent df863e5c
...@@ -1029,12 +1029,23 @@ class MetaBuildWrapper(object): ...@@ -1029,12 +1029,23 @@ class MetaBuildWrapper(object):
# because in python 3 vpython will no longer have its current 'viral' # because in python 3 vpython will no longer have its current 'viral'
# qualities and will require explicit usage to opt in to. # qualities and will require explicit usage to opt in to.
prefix = getattr(sys, "real_prefix", sys.prefix) prefix = getattr(sys, "real_prefix", sys.prefix)
python_exe = ('%s\\bin\\python.exe' if self.platform.startswith('win') else python_exe = 'python.exe' if self.platform.startswith('win') else 'python'
'%s/bin/python') % prefix # The value of prefix varies. Sometimes it extends to include the bin/
if os.path.isfile(python_exe): # directory of the python install such that prefix/python is the
cmd.append('--script-executable=%s' % python_exe) # interpreter, and other times prefix/bin/python is the interpreter.
# Therefore we need to check both. Also, it is safer to check prefix/bin
# first because there have been previous installs where prefix/bin/python
# was the real binary and prefix/python was actually vpython-native.
possible_python_locations = [
os.path.join(prefix, 'bin', python_exe),
os.path.join(prefix, python_exe),
]
for p in possible_python_locations:
if os.path.isfile(p):
cmd.append('--script-executable=%s' % p)
break
else: else:
self.Print('python interpreter not under %s/bin' % prefix) self.Print('python interpreter not under %s' % prefix)
ret, output, _ = self.Run(cmd) ret, output, _ = self.Run(cmd)
if ret: if ret:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment