Question: One of the core files **classes/stock/StockAvailable.php** contains:

```
class StockAvailableCore extends ObjectModel
{
   public static function getQuantityAvailableByProduct($id_product = null, $id_product_attribute = null, $id_shop = null)
     {
       ...
     }
  ...
}

```

I want to call this **getQuantityAvailableByProduct()** method from my module.

So I tried to include this class (and it's father class and father's interface), extend it and call method like this:

```
require_once('../../src/Core/Foundation/Database/EntityInterface.php');
require_once('../../classes/ObjectModel.php');
require_once('../../classes/stock/StockAvailable.php');

$MyClass = new StockAvailableCore();

$MyClass->getStockAvailableIdByProductId($id);

```

And the error that I'm getting:

```
PHP Fatal error:  Uncaught Error: Class 'ObjectModel' not found in /home/mantas/Server/honey/classes/stock/StockAvailable.php:34

```

What am i missing? And is this the correct way to extend a class and call method?

Answer: 
In case someone else is ok with getting Python3.6 installed as a side effect (python3.7-distutils introduces it as pointed out by OP). This will install Python3.7 making it default and have the latest available `pip` using your python3.7 installation 

```
FROM ubuntu:18.04

# Upgrade installed packages
RUN apt-get update && apt-get upgrade -y && apt-get clean

# (...)

# Python package management and basic dependencies
RUN apt-get install -y curl python3.7 python3.7-dev python3.7-distutils

# Register the version in alternatives
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1

# Set python 3 as the default python
RUN update-alternatives --set python /usr/bin/python3.7

# Upgrade pip to latest version
RUN curl -s https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
    python get-pip.py --force-reinstall && \
    rm get-pip.py

# (...)

```
I'm not really sure why these dependencies exist in the first place. As a hack, you could force install `python3-distutils` without the dependencies using `dpkg`, then edit out the dependencies in `/var/lib/dpkg/status` so that dpkg doesn't think it's broken.

```
apt --download-only install --no-install-recommends -y python3-distutils && \
dpkg --force-all -i /var/cache/apt/archives/python3-distutils*.deb && \
sed -i -E "s|Depends: python3 \(>= 3.6.7-1~\), python3 \(<< 3.9\), python3-lib2to3 \(>= 3.6.4\)|Depends:|" /var/lib/dpkg/status;

```

Subsequently, installing other python versions will see the distutils requirement as satisfied.

This works and I've managed to use this reliably on Ubuntu Bionic, but this is fragile and there may be some landmines I'm not aware of.

Alternatively, using the deadsnakes repos also resolves this. You can use this on Ubuntu Bionic providing python version as a build arg.

```
ARG PYTHON_VERSION=3.9

# example
RUN add-apt-repository -y ppa:deadsnakes/ppa && \
    apt update && \
    if [ "$PYTHON_VERSION" != "3.6" ]; then \
         apt install -y --no-install-recommends python${PYTHON_VERSION}-distutils; \
    else \
        apt install -y --no-install-recommends python3-distutils; \
    fi \
    && \
    apt install -y --no-install-recommends \
        python${PYTHON_VERSION} \
        python${PYTHON_VERSION}-venv \
        python${PYTHON_VERSION}-dev \
    && \
    # optionally apt purge unnecessary packages here...
    rm -rf /var/cache/apt/* /var/lib/apt/lists/* /var/log/*

# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH

```

Depending how you add the deadsnakes repo to your sources list, you may also need to install `software-properties-common` and `gnupg`.