0

I want to install PL/Python on my postgres database. I am using a binary manager on postgres pgenv. These are the steps I am following to install the procedural language:

  • I have downloaded the PL/Python source code from the PostgreSQL contrib repository

  • After connecting to the PL/Python source code directory, i run the commands

make 
make install
  • I am getting the error:
Makefile:5: ../../../src/Makefile.global: No such file or directory
Makefile:103: /src/Makefile.shlib: No such file or directory
make: *** No rule to make target `/src/Makefile.shlib'.  Stop.
Makefile:5: ../../../src/Makefile.global: No such file or directory
Makefile:103: /src/Makefile.shlib: No such file or directory
make: *** No rule to make target `/src/Makefile.shlib'.  Stop.

The error occurs because the build process for PL/Python is unable to locate the necessary PostgreSQL source files and makefiles. I have already checked and verified that the pg_config environment variable is pointing to the correct path.

After looking and referring to the pgenv docs. I Created a configuration file named default.conf inside the .pgenv/config/ directory and added the following line to the default.conf file to specify the --with-python option during the build process:

`PGENV_CONFIGURE_OPTIONS=(--with-python)`

Then i ran

`pgenv install 13.4`

Getting the error:

gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  command.o common.o copy.o crosstabview.o describe.o help.o input.o large_obj.o mainloop.o prompt.o psqlscanslash.o sql_help.o startup.o stringutils.o tab-complete.o variables.o -L../../../src/port -L../../../src/common -L../../../src/fe_utils -lpgfeutils -L../../../src/common -lpgcommon -L../../../src/port -lpgport -L../../../src/interfaces/libpq -lpq -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk   -Wl,-dead_strip_dylibs   -lpgcommon -lpgport -lz -lreadline -lm  -o psql
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C pl all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C plpgsql all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C plpython all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src all
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -I../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o plpy_cursorobject.o plpy_cursorobject.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -I../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o plpy_elog.o plpy_elog.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_comp.o pl_comp.c
In file included from plpy_cursorobject.c:14:
In file included from In file included from plpy_elog.c./plpy_cursorobject.h::108:
:
In file included from In file included from ./plpy_elog.h./plpy_typeio.h::810:
:
./plpython.h:98:./plpython.h:98:1010::  fatal error: fatal error: 'eval.h' file not found'eval.h' file not found

#include <eval.h>#include <eval.h>

         ^~~~~~~~         ^~~~~~~~

1 error generated.
make[3]: *** [plpy_elog.o] Error 1
make[3]: *** Waiting for unfinished jobs....
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_exec.o pl_exec.c
1 error generated.
make[3]: *** [plpy_cursorobject.o] Error 1
make[2]: *** [all-plpython-recurse] Error 2
make[2]: *** Waiting for unfinished jobs....
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_funcs.o pl_funcs.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_gram.o pl_gram.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_handler.o pl_handler.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I. -I. -I../../../../src/include  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk    -c -o pl_scanner.o pl_scanner.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -bundle -multiply_defined suppress -o plpgsql.so  pl_comp.o pl_exec.o pl_funcs.o pl_gram.o pl_handler.o pl_scanner.o -L../../../../src/port -L../../../../src/common  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk   -Wl,-dead_strip_dylibs    -bundle_loader ../../../../src/backend/postgres
make[1]: *** [all-pl-recurse] Error 2
make: *** [world-src-recurse] Error 2
Ishaan Adarsh
  • 197
  • 1
  • 11
  • 1) `plpythonu` is not a contrib module it is part of the core Postgres code. You will need to download the complete Postgres source from here [Postgres source](https://www.postgresql.org/ftp/source/) and build it. 2) How did you install your Postgres database? – Adrian Klaver Jul 21 '23 at 15:44
  • Installed it using `pgenv` -> `* 15.0 pgsql-15.0` – Ishaan Adarsh Jul 21 '23 at 15:58
  • Are you sure `plpythonu` is not already built? This [pgenv](https://github.com/theory/pgenv): *Optional dependencies: Perl 5 - To build PL/Perl Python - To build PL/Python* implies that it will/can be built. – Adrian Klaver Jul 21 '23 at 16:05
  • no it isn't, when i am running the command `CREATE EXTENSION plpyhtonu` is showing the error: `ERROR: extension "plpyhtonu" is not available DETAIL: Could not open extension control file "/Users/spartacus/.pgenv/pgsql-15.0/share/extension/plpyhtonu.control": No such file or directory. HINT: The extension must first be installed on the system where PostgreSQL is running.` – Ishaan Adarsh Jul 21 '23 at 16:42
  • 1
    Then I believe you will need to modify the build per the instructions here [pgenv](https://github.com/theory/pgenv): *pgenv build* The example shows doing that for `plperl` using `--with-perl`. The corresponding argument for `plpythonu` would be `--with-python`. – Adrian Klaver Jul 21 '23 at 16:50
  • Tired this but still getting the same error. Probably need to contect the maintainers of this repo for more details. – Ishaan Adarsh Jul 22 '23 at 06:34
  • Why not use a different packaging system? – Adrian Klaver Jul 22 '23 at 15:04
  • Probably will if this doesn’t work out. Actually this system is a breeze to work with overall but the main problem is installation. I have reached out to the maintainers and hopefully they have an answer. – Ishaan Adarsh Jul 22 '23 at 15:54
  • Are you still doing *... connecting to the PL/Python source code directory ...*? That is not necessary as the plpython code is in the core source. – Adrian Klaver Jul 22 '23 at 16:00
  • no I am not connecting the pl/python source code directory. I searched around for the control file in the extension directory like pgplsql has but I couldn't find it – Ishaan Adarsh Jul 22 '23 at 16:11
  • It's there [plpython src](https://git.postgresql.org/gitweb/?p=postgresql.git;a=tree;f=src/pl/plpython;h=5d18b87b42e382a8d568c335e62d5eed69c298b8;hb=HEAD) `plpython3u.control`. Though that does not come into play until after the build, when you do `CREATE EXTENSION plpython3u`. – Adrian Klaver Jul 22 '23 at 16:27
  • Actually the control files for extensions is present in the `.pgenv/pgsql-10.3/share/extension` location, languages like pgplsql’s control file is present. As I installed this postgres version along with python, the control file is supposed to be there, inbuilt but it isn’t. I have raised this issue to the maintainers also, hope this gets solved soon. – Ishaan Adarsh Jul 22 '23 at 17:05
  • 1) That is where is ends up after the extension is built and installed, which you indicate has not happened. 2) This `.pgenv/pgsql-10.3/share/extension` is for Postgres 10.3 and earlier you said you where working with Postgres 15. – Adrian Klaver Jul 22 '23 at 18:08
  • 1) I downloaded `pgenv` and built with `PGENV_CONFIGURE_OPTIONS=(--with-python)` in `.pgenv/config/default.conf` and it built `plpython3u` and I could `CREATE EXTENSION plpython3u`. **Note**: `plpythonu` is not available in Postgres 15+, also earlier you showed `CREATE EXTENSION plpyhtonu` which should be `CREATE EXTENSION plpythonu` in 14-, though I would use `plpython3u` any way. 2) I have the Python dev libraries installed, you might want to check that on your end. – Adrian Klaver Jul 22 '23 at 18:36

0 Answers0