Skip to content

Provide a working default pg_ctl location on Windows #1399

Description

@fizyk

postgresql_exec defaults to /usr/lib/postgresql/14/bin/pg_ctl (pytest_postgresql/plugin.py:147), a Linux path that can never exist on Windows. Windows users always fall through to pg_config --bindir, and the Windows installer does not put pg_config on PATH — so discovery fails and the fixture cannot start a server without an explicit --postgresql-exec.

What we want

  1. Make the postgresql_exec default platform-aware, or drop the hardcoded default in favour of discovery.
  2. Extend _pg_exe (pytest_postgresql/factories/process.py) to probe %ProgramFiles%\PostgreSQL\*\bin\pg_ctl.exe, newest version first, then shutil.which("pg_ctl").
  3. Drop --postgresql-exec from single-postgres-windows.yml and delete .github/actions/detect-pg-ctl, so CI exercises real discovery instead of bypassing it.

Where to look

  • .github/actions/detect-pg-ctl/action.yml — the discovery logic already exists here in PowerShell (Program Files path, then Get-Command pg_ctl). Port it into _pg_exe.
  • tests/test_pg_exe.py::test_windows_executable_suffix_is_probed — how to unit-test Windows path handling from Linux CI, by patching PG_CTL_NAMES.
  • os.access(path, os.X_OK) ignores X_OK on Windows, so the executable check in _pg_exe is an existence test there. Skip any permission-based test on Windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions