blob: c7254a9dbc5e9a30063c15f9bcbf2a2d6cba9435 [file] [log] [blame] [edit]
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This is based on src/platform2/common-mk/chromite_init.py
"""Find chromite and add it to sys.path."""
from pathlib import Path
import sys
TOP_DIR = Path(__file__).resolve().parent.parent
# Find chromite! Assume the layout:
# ~/chromiumos/ -- can be anywhere
# chromite/
# src/third_party/rust_crates/
SOURCE_ROOT = TOP_DIR.parent.parent.parent
if not (SOURCE_ROOT / "chromite").is_dir():
# When running in an ebuild, the platform2/ tree is created in a tempdir.
SOURCE_ROOT = Path("/mnt/host/source")
sys.path.insert(0, str(SOURCE_ROOT))