From 6dde987cfb0522dba4fa2c8fcd2ee32fb7312cd3 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 2 Sep 2026 17:29:18 +0100 Subject: [PATCH] run_setup: defer psycopg2 import so --help works without it Co-Authored-By: Claude Opus 4.8 --- run_setup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run_setup.py b/run_setup.py index cd18fec..542d49a 100644 --- a/run_setup.py +++ b/run_setup.py @@ -28,8 +28,6 @@ import argparse from pathlib import Path from typing import Dict -import psycopg2 - SQL_DIR = Path(__file__).parent / "sql" CONFIG_FILE = Path(__file__).parent / "db_config.json" @@ -150,6 +148,13 @@ def main() -> int: p.add_argument("--yes", action="store_true", help="Skip confirmation prompts") args = p.parse_args() + try: + import psycopg2 + except ModuleNotFoundError: + print("[FAIL] psycopg2 not installed. Run inside an environment that has " + "it (e.g. the TSAPI_SERIESDB_PG_PY venv), or: pip install psycopg2-binary") + return 1 + cfg = load_config(args) print("=" * 70)