Run a project-internal Python script and stream its output.
(script: Path, *args: str)
| 47 | |
| 48 | |
| 49 | def _run_python(script: Path, *args: str) -> int: |
| 50 | """Run a project-internal Python script and stream its output.""" |
| 51 | cmd = [sys.executable, str(script), *args] |
| 52 | env = os.environ.copy() |
| 53 | existing_pythonpath = env.get("PYTHONPATH") |
| 54 | paths = [str(PROJECT_ROOT)] |
| 55 | if existing_pythonpath: |
| 56 | paths.append(existing_pythonpath) |
| 57 | env["PYTHONPATH"] = os.pathsep.join(paths) |
| 58 | typer.echo(f"$ {' '.join(cmd)}") |
| 59 | completed = subprocess.run(cmd, cwd=str(PROJECT_ROOT), env=env) |
| 60 | return completed.returncode |
| 61 | |
| 62 | |
| 63 | def _run_wiki(*args: str) -> int: |