Skip to content

Commit

Permalink
Reland #5 of "Force Python 3 to be used in build.""
Browse files Browse the repository at this point in the history
This CL tries again to switch the compile to use Python3
by default. Earlier attempts weren't actually testing against
Python3 because mb.py was overriding the GN dotfile.

This CL changes that, and a long series of fixes between that
discovery and now have landed, so I think we're ready to try
again.

Bug: 1112471
Change-Id: I2d6ffe36692574828be972d7f0bdd9bbf4d9ef83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2645211
Commit-Queue: Dirk Pranke <[email protected]>
Reviewed-by: Bruce Dawson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#863527}
  • Loading branch information
dpranke authored and Chromium LUCI CQ committed Mar 16, 2021
1 parent 91e5779 commit 9ad088f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import("//third_party/angle/dotfile_settings.gni")
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"

# The python interpreter to use by default. On Windows, this will look
# for python3.exe and python3.bat.
script_executable = "python3"

# These arguments override the default values for items in a declare_args
# block. "gn args" in turn can override these.
#
Expand Down
27 changes: 0 additions & 27 deletions tools/mb/mb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,33 +1087,6 @@ def RunGNGen(self, vals, compute_inputs_for_analyze=False, check=True):
self.WriteFile(gn_runtime_deps_path, '\n'.join(labels) + '\n')
cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)

# Detect if we are running in a vpython interpreter, and if so force GN to
# use the real python interpreter. crbug.com/1049421
# This ensures that ninja will only use the real python interpreter and not
# vpython, so that any python scripts in the build will only use python
# modules vendored into //third_party.
# This can be deleted when python 3 becomes the only supported interpreter,
# because in python 3 vpython will no longer have its current 'viral'
# qualities and will require explicit usage to opt in to.
prefix = getattr(sys, "real_prefix", sys.prefix)
python_exe = 'python.exe' if self.platform.startswith('win') else 'python'
# The value of prefix varies. Sometimes it extends to include the bin/
# directory of the python install such that prefix/python is the
# 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:
self.Print('python interpreter not under %s' % prefix)

ret, output, _ = self.Run(cmd)
if ret != 0:
if self.args.json_output:
Expand Down

0 comments on commit 9ad088f

Please sign in to comment.