Make sys a top-level import in gclient_paths.

sys takes essentially no time to import (I think possibly because
it's a built-in?), and importing it as-needed is fragile. Make
it a top-level import to gclient_paths to prevent future breakages.

BUG=939959

Change-Id: I1ebe1260afd927355d668acf3cab5067ff0a2e03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1515669
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
changes/69/1515669/3
Dirk Pranke 6 years ago committed by Commit Bot
parent 8195bd9e8d
commit 112a77f4bf

@ -4,8 +4,11 @@
# This file is imported by various thin wrappers (around gn, clang-format, ...),
# so it's meant to import very quickly. To keep it that way don't add more
# code, and even more importantly don't add more toplevel import statements.
# code, and even more importantly don't add more toplevel import statements,
# particularly for modules that are not builtin (see sys.builtin_modules_names,
# os isn't built in, but it's essential to this file).
import os
import sys
def FindGclientRoot(from_dir, filename='.gclient'):
@ -23,7 +26,6 @@ def FindGclientRoot(from_dir, filename='.gclient'):
if path != real_from_dir:
entries_filename = os.path.join(path, filename + '_entries')
if not os.path.exists(entries_filename):
import sys
# If .gclient_entries does not exist, a previous call to gclient sync
# might have failed. In that case, we cannot verify that the .gclient
# is the one we want to use. In order to not to cause too much trouble,
@ -106,7 +108,6 @@ def GetBuildtoolsPlatformBinaryPath():
if not buildtools_path:
return None
import sys
if sys.platform.startswith(('cygwin', 'win')):
subdir = 'win'
elif sys.platform == 'darwin':
@ -120,7 +121,6 @@ def GetBuildtoolsPlatformBinaryPath():
def GetExeSuffix():
"""Returns '' or '.exe' depending on how executables work on this platform."""
import sys
if sys.platform.startswith(('cygwin', 'win')):
return '.exe'
return ''

Loading…
Cancel
Save