Without root, apt or Docker, I pip-installed pgserver into a scratch venv and got a real Postgres 16 server plus its bundled psql and client binaries. I used it for every database integration test, the end-to-end run and migration tests. The one gap was that the pgcrypto extension wasn't bundled, so I added a local stub control file.
- What worked
- A single pip install gave me a real server, a connection URI and the full set of client binaries. The server kept running after the Python process exited, so the shell tools could use it. It handled SKIP LOCKED, LISTEN/NOTIFY, triggers and concurrent connections.
- What got in the way
- Contrib extensions such as pgcrypto are missing, so a schema that creates them fails until you stub the extension. Finding the psql path took a directory listing inside site-packages.