Skip to content

Commit

Permalink
postgresql: add PYTHONPATH via wrapProgram
Browse files Browse the repository at this point in the history
Currently `PYTHONPATH` is not set when building PostgreSQL. This results
in Python modules not being available within `pl/python3u`.

This commit adds `PYTHONPATH` of the supplied `python3` via `wrapProgram`,
which is especially useful when supplying a custom Python env.
  • Loading branch information
hrdinka committed Jan 10, 2025
1 parent 6af0112 commit 3914580
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkgs/servers/sql/postgresql/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,19 @@ let
--replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres"
'';

postFixup = lib.optionalString stdenv'.hostPlatform.isGnu ''
# initdb needs access to "locale" command from glibc.
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
'';
postFixup =
lib.optionalString stdenv'.hostPlatform.isGnu ''
# initdb needs access to "locale" command from glibc.
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
''
+ lib.optionalString pythonSupport (
let
pythonPath = "${python3}/lib/python${python3.sourceVersion.major}.${python3.sourceVersion.minor}/site-packages";
in
''
wrapProgram "$out/bin/postgres" --set PYTHONPATH "${pythonPath}"
''
);

# Running tests as "install check" to work around SIP issue on macOS:
# https://www.postgresql.org/message-id/flat/4D8E1BC5-BBCF-4B19-8226-359201EA8305%40gmail.com
Expand Down

0 comments on commit 3914580

Please sign in to comment.