refactor: read the repo root from core.paths

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 13:46:15 +01:00
1 parent 6465bd99b1
commit 18e91f8c07
7 files changed
+15 -14

No files matched your search

+2 -1
View File
@@ -41,6 +41,7 @@ from model.declarations import merged_platform_declared_contents
from model.platforms import load_platform_config
from resolve.content import content_fits, name_match_size_ok
from core.hashing import parse_md5_list
from core.paths import REPO_ROOT
from model.safeparse import require_yaml
from resolve.localfile import resolve_local_file
from resolve.standalone import platform_layouts, standalone_set
@@ -465,7 +466,7 @@ class FileConsumers:
self._data_dir_registry = (
data_dir_registry if data_dir_registry is not None
else load_data_dir_registry(
str(Path(__file__).resolve().parent.parent / DEFAULT_PLATFORMS_DIR)
str(REPO_ROOT / DEFAULT_PLATFORMS_DIR)
)
)
self._sha1_by_path = {
+5 -5
View File
@@ -108,7 +108,7 @@ from model.platforms import load_platform_config
from model.safeparse import require_yaml, yaml_load
from model.declarations import declared_root
from resolve.standalone import platform_layouts, standalone_set
from core.paths import sanitize_pack_path
from core.paths import REPO_ROOT, sanitize_pack_path
import packresolve
from refresh_data_dirs import cache_lock, hold_data_dirs
from model import region
@@ -2424,7 +2424,7 @@ def generate_emulator_pack(
os.makedirs(output_dir, exist_ok=True)
data_registry = load_data_dir_registry(
options.get("platforms_dir") or os.path.join(os.path.dirname(__file__), "..", "platforms")
options.get("platforms_dir") or str(REPO_ROOT / "platforms")
)
region_drops: set[str] = (
emulator_region_drops(
@@ -4402,7 +4402,7 @@ def _run_platform_mode(
def _main(held: contextlib.ExitStack) -> None:
parser = _build_parser()
args = parser.parse_args()
from verify import work_from_repo_root
from model.cliargs import work_from_repo_root
work_from_repo_root(
args, parser,
@@ -5940,7 +5940,7 @@ def _start_manifest(
build = _ManifestBuild(
platform_name, platforms_dir, db, bios_dir, opts, config, emu_profiles,
zip_contents, data_registry, game_entries, plat_registry.get("install", {}),
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), pack_systems,
str(REPO_ROOT), pack_systems,
)
build.manifest_profiles = {
name: emu_profiles[name]
@@ -6213,7 +6213,7 @@ def _standalone_layouts(
that entry. Another is written whole. A data tree member is left to the
list's data directories.
"""
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
repo_root = str(REPO_ROOT)
known = {
copy["sha1"]
for entry in [*result["files"], *result.get("truth_files", [])]
+2 -2
View File
@@ -17,7 +17,7 @@ from model.largefiles import fetch_large_file
from core.hashing import cut_md5_owner
from resolve.content import declared_hash_verdict
from resolve.localfile import resolution_is_hash_exact, resolve_local_file
from core.paths import sanitize_pack_path
from core.paths import REPO_ROOT, sanitize_pack_path
from resolve.validation import inner_rom_check
# CLI-wide network policy. Public helpers can override it explicitly, while
# every CLI mode inherits --offline (including large-file release fallback).
@@ -32,7 +32,7 @@ def set_offline(value: bool) -> None:
def scratch_dir() -> str:
"""The repository's tmp/, never the system /tmp (a 4 GB tmpfs on WSL)."""
path = Path(__file__).resolve().parent.parent / "tmp"
path = REPO_ROOT / "tmp"
path.mkdir(exist_ok=True)
return str(path)
+1 -1
View File
@@ -10,7 +10,7 @@ from collections import Counter
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, TypedDict
from auto_fetch import DEFAULT_BIOS_DIR
from verify import DEFAULT_BIOS_DIR
from core.artifacts import _build_timestamp
from packpaths import MEDIA_MARKER, _has_path_conflict
from core.ziptools import build_zip_contents_index
+2 -1
View File
@@ -1149,7 +1149,8 @@ def main() -> None:
# root. Run from elsewhere, every file read as referenced by no platform
# and placed outside bios/. The files named are read from where they
# were typed.
from verify import REPO_ROOT, work_from_repo_root
from core.paths import REPO_ROOT
from model.cliargs import work_from_repo_root
if os.path.realpath(os.getcwd()) != os.path.realpath(REPO_ROOT):
args.files = [os.path.abspath(f) for f in args.files]
+2 -3
View File
@@ -95,7 +95,7 @@ from resolve.cores import (
from model.safeparse import require_yaml
from resolve.localfile import resolve_local_file
from resolve.standalone import platform_layouts, standalone_set as platform_standalone_set
from core.paths import sanitize_pack_path
from core.paths import REPO_ROOT, sanitize_pack_path
from resolve.categories import BIOS, EntryCategories
from resolve.launchers import LauncherLayer, declared_destinations, held_record, launcher_unproven
@@ -143,9 +143,8 @@ DEFAULT_PLATFORMS_DIR = "platforms"
DEFAULT_BIOS_DIR = "bios"
# The repository's platforms wherever the script runs from, for library calls
# that pass no directory.
_REPO_PLATFORMS = os.path.join(os.path.dirname(__file__), "..", "platforms")
_REPO_PLATFORMS = str(REPO_ROOT / "platforms")
DEFAULT_EMULATORS_DIR = "emulators"
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Status model: aligned with Batocera BiosStatus (batocera-systems:967-969)
+1 -1
View File
@@ -32,7 +32,7 @@ SIBLING_IMPORTS: dict[str, frozenset[str]] = {
# Top-level modules other modules of scripts/ import: library code that a
# later wave moves into a package.
NOT_YET_PACKAGED = frozenset({
"archive_build", "auto_fetch", "autorun", "build_port", "campaign", "campaign_profiles",
"archive_build", "autorun", "build_port", "campaign", "campaign_profiles",
"campaign_rules", "check_buildbot_system", "check_release_assets", "commit_rules", "core_probe",
"cross_reference", "dedup", "derivations", "generate_event_schema",
"generate_pack", "generate_readme", "generate_site", "manifestselect", "measurement_records",