Segfault from NumPy import after ROOT in PyROOT in Debian Docker image

So, I’m not sure why (I’m thinking some underlying dependencies in packages.txt were missing?) but the following build works:

In a directory with the following:

$ tree
.
├── Dockerfile
└── packages.txt

0 directories, 2 files

where packages.txt contains

# packages.txt
git
dpkg-dev
cmake
g++
gcc
binutils
libx11-dev
libxpm-dev
libxft-dev
libxext-dev
gfortran
libssl-dev
libpcre3-dev
xlibmesa-glu-dev
libglew1.5-dev
libftgl-dev
libfftw3-dev
libcfitsio-dev
graphviz-dev
libavahi-compat-libdnssd-dev
libldap2-dev
python3-dev
libxml2-dev
libkrb5-dev
libgsl0-dev
libqt4-dev
locales
ccache
wget
fonts-freefont-otf

and the Dockerfile is

ARG BASE_IMAGE=python:3.7-slim
FROM ${BASE_IMAGE} as base

SHELL [ "/bin/bash", "-c" ]

FROM base as builder

ARG ROOT_VERSION=6-20-00

# As this is builder can split up RUNs to make debugging easier
COPY packages.txt packages.txt
RUN apt-get -qq -y update && \
    apt-get -qq -y install $(cat packages.txt) && \
    apt-get -y autoclean && \
    apt-get -y autoremove && \
    rm -rf /var/lib/apt-get/lists/*
# c.f. https://root.cern.ch/building-root#options
RUN mkdir code && \
    cd code && \
    git clone --depth 5 https://github.com/root-project/root \
      --branch "v${ROOT_VERSION}" \
      --single-branch \
      "root-${ROOT_VERSION}" && \
    mkdir build && \
    cd build && \
    cmake \
      -Dall=OFF \
      -Dcxx14=ON \
      -Dpython=ON \
      -DPYTHON_EXECUTABLE=$(which python3) \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      ../root-${ROOT_VERSION} && \
    cmake --build . -- -j$(($(nproc) - 1)) && \
    cmake --build . --target install

FROM base
RUN apt-get -qq -y update && \
    apt-get -qq -y install \
      gcc \
      g++ \
      zlibc \
      libblas3 \
      zlib1g-dev \
      libbz2-dev \
      libx11-dev \
      libxext-dev \
      libxft-dev \
      libxml2-dev \
      libxpm-dev \
      libz-dev && \
    apt-get -y autoclean && \
    apt-get -y autoremove && \
    rm -rf /var/lib/apt-get/lists/*
# Use C.UTF-8 locale to avoid issues with ASCII encoding
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV PYTHONPATH=/usr/local/lib:$PYTHONPATH
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/include /usr/local/include
COPY --from=builder /usr/local/share /usr/local/share
COPY --from=builder /usr/local/etc /usr/local/etc
COPY --from=builder /usr/local/fonts /usr/local/fonts

WORKDIR /home/data
ENV HOME /home

ENTRYPOINT ["/bin/bash"]

the following build works

docker build . \
  -f Dockerfile \
  --build-arg BASE_IMAGE=python:3.7-slim \
  --build-arg ROOT_VERSION=6.20.00 \
  --tag test-build:latest

and the following import order works just fine

docker run \
  --rm \
  test-build:latest \
  -c "python -m pip install numpy; python -c 'import ROOT; import numpy as np; print(np.arange(10))'"

So not much to say, other than this works and sorry for the noise, but thank you for taking time to debug this.