mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
cros: disable Python caches in citc checkouts
Since citc doesn't support gitignore, it doesn't like it when you dirty checkouts with pyc/pyo files. Disable it here when running the launchers. Change-Id: I0fd65da489d477bcc3027cf0059ce7122bb90c6b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4983229 Commit-Queue: Mike Frysinger <vapier@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com>
This commit is contained in:
28
cros
28
cros
@@ -11,11 +11,12 @@ possible.
|
||||
It is intended to used strictly outside of the chroot.
|
||||
"""
|
||||
|
||||
import enum
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Optional
|
||||
from typing import List, NamedTuple, Optional, Tuple
|
||||
|
||||
# Min version of Python that we *want*. We warn for older versions.
|
||||
MIN_PYTHON_VER_SOFT = (3, 8)
|
||||
@@ -28,7 +29,14 @@ DEPOT_TOOLS_DIR = Path(__file__).resolve().parent
|
||||
CIPD_CACHE_DIR = DEPOT_TOOLS_DIR / '.cipd_bin_cros_python2'
|
||||
|
||||
|
||||
def _FindChromite(path: Path) -> Optional[Path]:
|
||||
class Checkout(NamedTuple):
|
||||
"""Some details about this checkout."""
|
||||
|
||||
root: Path
|
||||
chromite_dir: Path
|
||||
|
||||
|
||||
def _FindChromite(path: Path) -> Optional[Checkout]:
|
||||
"""Find the chromite dir in a repo, gclient, or submodule checkout."""
|
||||
path = path.resolve()
|
||||
# Depending on the checkout type (whether repo chromeos or gclient chrome)
|
||||
@@ -48,10 +56,8 @@ def _FindChromite(path: Path) -> Optional[Path]:
|
||||
|
||||
while path != Path("/"):
|
||||
for root, chromite_git_dir in roots:
|
||||
if all(
|
||||
(path / x).exists()
|
||||
for x in [root, chromite_git_dir]):
|
||||
return (path / chromite_git_dir).parent
|
||||
if all((path / x).exists() for x in [root, chromite_git_dir]):
|
||||
return Checkout(path, (path / chromite_git_dir).parent)
|
||||
path = path.parent
|
||||
return None
|
||||
|
||||
@@ -100,10 +106,16 @@ def _BootstrapVpython27():
|
||||
def main():
|
||||
_CheckPythonVersion()
|
||||
|
||||
chromite_dir = _FindChromite(Path.cwd())
|
||||
result = _FindChromite(Path.cwd())
|
||||
target = os.path.basename(sys.argv[0])
|
||||
if chromite_dir is None:
|
||||
if result is None:
|
||||
return _MissingErrorOut(target)
|
||||
root, chromite_dir = result
|
||||
|
||||
is_citc = (root.parent / ".citc").is_dir()
|
||||
if is_citc:
|
||||
# citc workspaces don't like dirty files like pyc.
|
||||
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
|
||||
|
||||
path = chromite_dir / "bin" / target
|
||||
|
||||
|
||||
Reference in New Issue
Block a user