mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-18 19:16:22 +00:00
* chore: new browseros-server binaries * bugfix: was writing chromium_patches/ in wrong location * patch: ntp footer disabled by default * patch: browseros alpha flag * patch: add log for port saving * chore: increment PATCH * feat: use packages/browseros as root_dir properly in context.py
46 lines
1.4 KiB
Python
Generated
46 lines
1.4 KiB
Python
Generated
#!/usr/bin/env python3
|
|
"""
|
|
Package root detection for BrowserOS build system
|
|
|
|
This module provides a single function to find the browseros package root
|
|
directory, regardless of the current working directory.
|
|
|
|
IMPORTANT: This module must have NO local imports to avoid circular dependencies.
|
|
It is imported by both context.py and env.py at module load time.
|
|
"""
|
|
|
|
import re
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_package_root() -> Path:
|
|
"""Find browseros package root by walking up looking for pyproject.toml.
|
|
|
|
Walks up from this file's location looking for a pyproject.toml that
|
|
contains the browseros package definition.
|
|
|
|
Returns:
|
|
Path to the browseros package root (e.g., packages/browseros/)
|
|
|
|
Raises:
|
|
RuntimeError: If package root cannot be found
|
|
"""
|
|
current = Path(__file__).resolve().parent
|
|
|
|
while current != current.parent:
|
|
pyproject = current / "pyproject.toml"
|
|
if pyproject.exists():
|
|
content = pyproject.read_text()
|
|
# Match name = "browseros" with flexible whitespace
|
|
if re.search(r'^name\s*=\s*["\']browseros["\']', content, re.MULTILINE):
|
|
return current
|
|
current = current.parent
|
|
|
|
raise RuntimeError(
|
|
"Could not find browseros package root. "
|
|
"Expected to find pyproject.toml with name = 'browseros' "
|
|
f"in ancestors of {Path(__file__).resolve()}"
|
|
)
|