diff --git a/packages/create-python-app-core/src/create_python_app_core/api.py b/packages/create-python-app-core/src/create_python_app_core/api.py index ec43767..4609cbd 100644 --- a/packages/create-python-app-core/src/create_python_app_core/api.py +++ b/packages/create-python-app-core/src/create_python_app_core/api.py @@ -2,6 +2,8 @@ from __future__ import annotations +import platform +import shutil import sys from collections.abc import Awaitable, Callable from pathlib import Path @@ -38,9 +40,22 @@ async def check_for_latest_version(package_name: str) -> str | None: def print_env_info() -> None: - """Print environment info then exit. Full implementation in #30.""" - print(f"create-python-app-core {__version__}") - print(f"Python {sys.version}") + """Print OS/Python/uv tooling versions for bug reports.""" + uv = shutil.which("uv") + git = shutil.which("git") + print(f"create-python-app-core: {__version__}") + print(f"Python: {sys.version.split()[0]} ({sys.executable})") + print(f"Platform: {platform.platform()}") + print(f"uv: {uv or 'not found'}") + print(f"git: {git or 'not found'}") + if uv: + import subprocess + + try: + out = subprocess.check_output(["uv", "--version"], text=True).strip() + print(f"uv version: {out}") + except OSError: + pass raise SystemExit(0) diff --git a/packages/create-python-app-core/tests/test_env_info.py b/packages/create-python-app-core/tests/test_env_info.py new file mode 100644 index 0000000..4e1b382 --- /dev/null +++ b/packages/create-python-app-core/tests/test_env_info.py @@ -0,0 +1,11 @@ +import pytest +from create_python_app_core.api import print_env_info + + +def test_print_env_info_exits(capsys: pytest.CaptureFixture[str]) -> None: + with pytest.raises(SystemExit) as ei: + print_env_info() + assert ei.value.code == 0 + out = capsys.readouterr().out + assert "Python:" in out + assert "Platform:" in out