monetdb

MonetDB set specific embedded python version


In a Linux environment, I'd like to be able to set the embedded python3 to a specific python version. My current monetDB install seems to use 3.7 even though all default python paths point to 3.8.6.

Is there a way to set my 3.8.6 install as the default embedded python3 version?


Solution

  • After some experimentation, the problem seems to be the following: because you are installing MonetDB using apt, the installation pulls the python version that the distribution has packaged in apt. I assume that you are building your container starting from python:3.8. This is based on Debian Buster that packages Python 3.7.

    In a bit more detail:

    I built a container using the following Dockerfile:

    FROM python:3.8
    
    RUN apt-get update
    RUN apt-get upgrade -y
    
    COPY ./monetdb.list /etc/apt/sources.list.d/
    COPY ./MonetDB-GPG-KEY /
    RUN apt-key add /MonetDB-GPG-KEY
    RUN apt-get update
    RUN apt-get install -y monetdb5-sql monetdb-client monetdb-python3
    

    with the files monetdb.list and MonetDB-GPG-KEY as described in the downloads page.

    I then created a database farm and a new database in the container, setting embedpy3 to true:

    root@bd0420e945e8:/# monetdbd create /tmp/dbfarm
    root@bd0420e945e8:/# monetdbd start /tmp/dbfarm
    root@bd0420e945e8:/# monetdb create -p monetdb pytestdb
    created database with password for monetdb user: pytestdb
    root@bd0420e945e8:/# monetdb set embedpy3=yes pytestdb
    

    Using mclient I created a Python UDF that returns as a string the version of the embedded python interpreter:

    CREATE FUNCTION pyversion () 
    RETURNS STRING 
    LANGUAGE python {
      import sys 
      return sys.version
    };
    

    When I called it I got the following result:

    sql>select pyversion();
    +-----------------------------------------------------+
    | %2                                                  |
    +=====================================================+
    | 3.7.3 (default, Jul 25 2020, 13:03:44)              |
    : [GCC 8.3.0]                                         :
    +-----------------------------------------------------+
    1 tuple
    

    I repeated the above process starting from a different distribution (Ubuntu Focal) that packages a different version of Python (It seems that Ubuntu has updated to Python 3.8.5 since the release of Focal).

    FROM ubuntu:20.04
    
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get install -y gnupg ca-certificates
    
    COPY ./monetdb.list /etc/apt/sources.list.d/
    COPY ./MonetDB-GPG-KEY /
    RUN apt-key add /MonetDB-GPG-KEY
    RUN apt-get update
    RUN apt-get install -y monetdb5-sql monetdb-client monetdb-python3
    
    

    In this container the function pyversion returns the following:

    sql>select pyversion();
    +-----------------------------------------------------+
    | %2                                                  |
    +=====================================================+
    | 3.8.5 (default, Jul 28 2020, 12:59:40)              |
    : [GCC 9.3.0]                                         :
    +-----------------------------------------------------+
    1 tuple
    

    In conclusion, I would suggest to either build MonetDB from source in the container (see the README for instructions), or build your container starting from a distribution that packages Python 3.8 in its package manager.