I frequently work with Postgres & Python and toggle between multiple versions of each. In Postgres, I keep a separate installation for each project, but I don't like git submodules and don't want to ship "pg_build.sh" scripts with the source code.
So, I built pgvenv as a Python shell package that, when installed, triggers a from-source installation of Postgres and installs it at venv's prefix. Could become handy at times I think.
You can roughly use it like this.
python3.11 -m venv ./venv
source ./venv/bin/activate
PGVERSION=17.4 pip install pgvenv --force-reinstall --no-cache-dir
initdb ./pgdata
postgres -D ./pgdata
Many things can go wrong with this in production, so should probably use for development only.