Add YAPF style + ignore, and format tracked Python files
This commit is contained in:
@@ -112,7 +112,10 @@ def run_platform_bootstrap(repo_root: Path) -> int:
|
||||
print("Running platform bootstrap script:", " ".join(cmd))
|
||||
rc = subprocess.run(cmd, cwd=str(repo_root))
|
||||
if rc.returncode != 0:
|
||||
print(f"Bootstrap script failed with exit code {rc.returncode}", file=sys.stderr)
|
||||
print(
|
||||
f"Bootstrap script failed with exit code {rc.returncode}",
|
||||
file=sys.stderr
|
||||
)
|
||||
return int(rc.returncode or 0)
|
||||
|
||||
|
||||
@@ -143,7 +146,9 @@ def _build_playwright_install_cmd(browsers: str | None) -> list[str]:
|
||||
if "all" in items:
|
||||
return base
|
||||
|
||||
allowed = {"chromium", "firefox", "webkit"}
|
||||
allowed = {"chromium",
|
||||
"firefox",
|
||||
"webkit"}
|
||||
invalid = [b for b in items if b not in allowed]
|
||||
if invalid:
|
||||
raise ValueError(
|
||||
@@ -172,7 +177,16 @@ def _install_deno(version: str | None = None) -> int:
|
||||
ps_cmd = f"iwr https://deno.land/x/install/install.ps1 -useb | iex; Install-Deno -Version {ver}"
|
||||
else:
|
||||
ps_cmd = "iwr https://deno.land/x/install/install.ps1 -useb | iex"
|
||||
run(["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", ps_cmd])
|
||||
run(
|
||||
[
|
||||
"powershell",
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass",
|
||||
"-Command",
|
||||
ps_cmd
|
||||
]
|
||||
)
|
||||
else:
|
||||
# POSIX: use curl + sh installer
|
||||
if version:
|
||||
@@ -220,7 +234,8 @@ def main() -> int:
|
||||
"--browsers",
|
||||
type=str,
|
||||
default="chromium",
|
||||
help="Comma-separated list of browsers to install: chromium,firefox,webkit or 'all' (default: chromium)",
|
||||
help=
|
||||
"Comma-separated list of browsers to install: chromium,firefox,webkit or 'all' (default: chromium)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--install-editable",
|
||||
@@ -234,7 +249,9 @@ def main() -> int:
|
||||
help="Install the Deno runtime (default behavior; kept for explicitness)",
|
||||
)
|
||||
deno_group.add_argument(
|
||||
"--no-deno", action="store_true", help="Skip installing Deno runtime (opt out)"
|
||||
"--no-deno",
|
||||
action="store_true",
|
||||
help="Skip installing Deno runtime (opt out)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--deno-version",
|
||||
@@ -312,7 +329,9 @@ def main() -> int:
|
||||
print("'playwright' package not found; installing it via pip...")
|
||||
run([sys.executable, "-m", "pip", "install", "playwright"])
|
||||
|
||||
print("Installing Playwright browsers (this may download several hundred MB)...")
|
||||
print(
|
||||
"Installing Playwright browsers (this may download several hundred MB)..."
|
||||
)
|
||||
try:
|
||||
cmd = _build_playwright_install_cmd(args.browsers)
|
||||
except ValueError as exc:
|
||||
@@ -346,7 +365,9 @@ def main() -> int:
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
print(f"Installing Python dependencies into local venv from {req_file}...")
|
||||
print(
|
||||
f"Installing Python dependencies into local venv from {req_file}..."
|
||||
)
|
||||
run([str(venv_python), "-m", "pip", "install", "-r", str(req_file)])
|
||||
|
||||
if not args.no_playwright:
|
||||
@@ -354,7 +375,9 @@ def main() -> int:
|
||||
print("'playwright' package not installed in venv; installing it...")
|
||||
run([str(venv_python), "-m", "pip", "install", "playwright"])
|
||||
|
||||
print("Installing Playwright browsers (this may download several hundred MB)...")
|
||||
print(
|
||||
"Installing Playwright browsers (this may download several hundred MB)..."
|
||||
)
|
||||
try:
|
||||
cmd = _build_playwright_install_cmd(args.browsers)
|
||||
except ValueError as exc:
|
||||
@@ -373,7 +396,11 @@ def main() -> int:
|
||||
print("Verifying top-level 'CLI' import in venv...")
|
||||
try:
|
||||
rc = subprocess.run(
|
||||
[str(venv_python), "-c", "import importlib; importlib.import_module('CLI')"],
|
||||
[
|
||||
str(venv_python),
|
||||
"-c",
|
||||
"import importlib; importlib.import_module('CLI')"
|
||||
],
|
||||
check=False,
|
||||
)
|
||||
if rc.returncode == 0:
|
||||
@@ -418,7 +445,9 @@ def main() -> int:
|
||||
else:
|
||||
with pth_file.open("w", encoding="utf-8") as fh:
|
||||
fh.write(str(repo_root) + "\n")
|
||||
print(f"Wrote .pth adding repo root to venv site-packages: {pth_file}")
|
||||
print(
|
||||
f"Wrote .pth adding repo root to venv site-packages: {pth_file}"
|
||||
)
|
||||
|
||||
# Re-check whether CLI can be imported now
|
||||
rc2 = subprocess.run(
|
||||
@@ -436,7 +465,9 @@ def main() -> int:
|
||||
"Adding .pth did not make top-level 'CLI' importable; consider creating an egg-link or checking the venv."
|
||||
)
|
||||
except Exception as exc:
|
||||
print(f"Warning: failed to verify or modify site-packages for top-level CLI: {exc}")
|
||||
print(
|
||||
f"Warning: failed to verify or modify site-packages for top-level CLI: {exc}"
|
||||
)
|
||||
|
||||
# Optional: install Deno runtime (default: install unless --no-deno is passed)
|
||||
install_deno_requested = True
|
||||
@@ -572,9 +603,14 @@ python -m medeia_macina.cli_entry @args
|
||||
"$bin = '{bin}';"
|
||||
"$cur = [Environment]::GetEnvironmentVariable('PATH','User');"
|
||||
"if ($cur -notlike \"*$bin*\") {[Environment]::SetEnvironmentVariable('PATH', ($bin + ';' + ($cur -ne $null ? $cur : '')), 'User')}"
|
||||
).format(bin=str_bin.replace("\\", "\\\\"))
|
||||
).format(bin=str_bin.replace("\\",
|
||||
"\\\\"))
|
||||
subprocess.run(
|
||||
["powershell", "-NoProfile", "-Command", ps_cmd], check=False
|
||||
["powershell",
|
||||
"-NoProfile",
|
||||
"-Command",
|
||||
ps_cmd],
|
||||
check=False
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -583,7 +619,10 @@ python -m medeia_macina.cli_entry @args
|
||||
|
||||
else:
|
||||
# POSIX
|
||||
user_bin = Path(os.environ.get("XDG_BIN_HOME", str(home / ".local/bin")))
|
||||
user_bin = Path(
|
||||
os.environ.get("XDG_BIN_HOME",
|
||||
str(home / ".local/bin"))
|
||||
)
|
||||
user_bin.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
mm_sh = user_bin / "mm"
|
||||
@@ -688,7 +727,10 @@ python -m medeia_macina.cli_entry @args
|
||||
return 0
|
||||
|
||||
except subprocess.CalledProcessError as exc:
|
||||
print(f"Error: command failed with exit {exc.returncode}: {exc}", file=sys.stderr)
|
||||
print(
|
||||
f"Error: command failed with exit {exc.returncode}: {exc}",
|
||||
file=sys.stderr
|
||||
)
|
||||
return int(exc.returncode or 1)
|
||||
except Exception as exc: # pragma: no cover - defensive
|
||||
print(f"Unexpected error: {exc}", file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user