kjf
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
@@ -11,7 +11,7 @@ Medios-Macina is a CLI media manager and toolkit focused on downloading, tagging
|
||||
|
||||
## Quick start ⚡
|
||||
|
||||
Prefer an automated setup? See `docs/BOOTSTRAP.md` and use `scripts/bootstrap.ps1` (Windows) or `scripts/bootstrap.sh` (Linux/macOS) to create a venv and install the project. Alternatively, run the opinionated helper: `python ./scripts/setup.py` which creates a `.venv` at the repo root, installs dependencies into it, writes convenient `mm` launchers in the project root, and installs a global `mm` shim into your user PATH so you can run `mm` from anywhere.
|
||||
`docs/BOOTSTRAP.md` and use `scripts/bootstrap.ps1` (Windows) or `scripts/bootstrap.sh` (Linux/macOS) to create a venv and install the project. Alternatively, simply run the opinionated helper: `python ./scripts/setup.py`. By default (no flags), `setup.py` will auto-detect your platform and run the matching bootstrap script in **non-interactive (quiet)** mode so you don't need to run the platform-specific script yourself. Note: the Deno installer can require interactive input on some systems; if the automated Deno install fails, the script will warn and you can install Deno manually by following `docs/BOOTSTRAP.md`.
|
||||
|
||||
1. Install Python requirements:
|
||||
|
||||
|
||||
@@ -8,8 +8,13 @@ downloads Playwright browser binaries by running `python -m playwright install`.
|
||||
By default this script installs **Chromium** only to conserve space; pass
|
||||
`--browsers all` to install all supported engines (chromium, firefox, webkit).
|
||||
|
||||
When invoked without any arguments, `setup.py` will automatically select and
|
||||
run the platform-specific bootstrap helper (`scripts/bootstrap.ps1` on Windows
|
||||
or `scripts/bootstrap.sh` on POSIX) in **non-interactive (quiet)** mode so a
|
||||
single `python ./scripts/setup.py` call does the usual bootstrap on your OS.
|
||||
|
||||
Usage:
|
||||
python ./scripts/setup.py # install deps and playwright browsers
|
||||
python ./scripts/setup.py # install deps and playwright browsers (or run platform bootstrap if no args)
|
||||
python ./scripts/setup.py --skip-deps
|
||||
python ./scripts/setup.py --playwright-only
|
||||
|
||||
@@ -41,6 +46,59 @@ def run(cmd: list[str]) -> None:
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
# Helpers to find shell executables and to run the platform-specific
|
||||
# bootstrap script (scripts/bootstrap.sh or scripts/bootstrap.ps1).
|
||||
def _find_powershell() -> str | None:
|
||||
for name in ("pwsh", "powershell"):
|
||||
p = shutil.which(name)
|
||||
if p:
|
||||
return p
|
||||
return None
|
||||
|
||||
|
||||
def _find_shell() -> str | None:
|
||||
for name in ("bash", "sh"):
|
||||
p = shutil.which(name)
|
||||
if p:
|
||||
return p
|
||||
return None
|
||||
|
||||
|
||||
def run_platform_bootstrap(repo_root: Path) -> int:
|
||||
"""Run the platform bootstrap script in quiet/non-interactive mode if present.
|
||||
|
||||
Returns the script exit code (0 on success). If no script is present this is a
|
||||
no-op and returns 0.
|
||||
"""
|
||||
ps1 = repo_root / "scripts" / "bootstrap.ps1"
|
||||
sh_script = repo_root / "scripts" / "bootstrap.sh"
|
||||
|
||||
system = platform.system().lower()
|
||||
|
||||
if system == "windows" and ps1.exists():
|
||||
exe = _find_powershell()
|
||||
if not exe:
|
||||
print("PowerShell not found; cannot run bootstrap.ps1", file=sys.stderr)
|
||||
return 1
|
||||
cmd = [exe, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", str(ps1), "-Quiet"]
|
||||
elif sh_script.exists():
|
||||
shell = _find_shell()
|
||||
if not shell:
|
||||
print("Shell not found; cannot run bootstrap.sh", file=sys.stderr)
|
||||
return 1
|
||||
# Use -q (quiet) to skip interactive prompts when supported.
|
||||
cmd = [shell, str(sh_script), "-q"]
|
||||
else:
|
||||
# Nothing to run
|
||||
return 0
|
||||
|
||||
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)
|
||||
return int(rc.returncode or 0)
|
||||
|
||||
|
||||
def playwright_package_installed() -> bool:
|
||||
try:
|
||||
import playwright # type: ignore
|
||||
@@ -131,6 +189,17 @@ def main() -> int:
|
||||
|
||||
repo_root = Path(__file__).resolve().parent.parent
|
||||
|
||||
# If invoked without any arguments, prefer to delegate to the platform
|
||||
# bootstrap script (if present). The bootstrap scripts support a quiet/
|
||||
# non-interactive mode, which we use so "python ./scripts/setup.py" just
|
||||
# does the right thing on Windows and *nix without extra flags.
|
||||
if len(sys.argv) == 1:
|
||||
rc = run_platform_bootstrap(repo_root)
|
||||
if rc != 0:
|
||||
return rc
|
||||
print("Platform bootstrap completed successfully.")
|
||||
return 0
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
print("Warning: Python 3.8+ is recommended.", file=sys.stderr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user