Python is becoming more and more a data analysis tool with the release of analysis packages such as chainer and tensorflow. It is attracting attention. There is a function called "PL / Python" that can use such Python as a function implementation language of PostgreSQL.
By default PL / Python uses the system Python. On the other hand, if you do not want to pollute the Python of the system, it seems that you may separate the Python environment with pyenv and put the analysis package.
Therefore, I investigated how to use Python installed by pyenv for the PL / Python execution environment.
PL / Python references libpython ~~ .so
.
Since the shared library is not installed by normal pyenv install
Do the following:
CONFIGURE_OPTS="--enable-shared" pyenv install 2.7.10
This is OK on the pyenv side
PostgreSQL compiles from source.
https://github.com/postgres/postgres
From here, I think you can do git clone
.
Then, with configure
, do as follows.
./configure --prefix=/home/user/pgsql/pgsql9_5 --with-python=yes PYTHON=/home/user/.pyenv/versions/2.7.10/bin/python
You may or may not add the --prefix
.
The important thing is
--with-python=yes
When
PYTHON=/home/user/.pyenv/versions/2.7.10/bin/python
If you don't add --with-python = yes
, PL / Python won't compile in the first place.
PYTHON = / home / user / .pyenv / versions / 2.7.10 / bin / python
was installed with pyenv
Specifies the location of Python binaries.
PL / Python will then be compiled to use pyenv's Python.
When you execute configure
, the following description will be written in the generatedMakefile.global
.
python_includespec = -I/home/user/.pyenv/versions/2.7.10/include/python2.7
python_libdir = /home/user/.pyenv/versions/2.7.10/lib
python_libspec = -L/home/user/.pyenv/versions/2.7.10/lib -lpython2.7
After that, if you make; make install
PostgreSQL, the PL / Python execution environment will be Python installed with pyenv.
I compiled the whole PostgreSQL, but should I compile only PL / Python?
Recommended Posts