Skip to content

Instantly share code, notes, and snippets.

@acidbourbon
Last active September 3, 2019 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidbourbon/48fdc0df540614c11238a9e6765be3ae to your computer and use it in GitHub Desktop.
Save acidbourbon/48fdc0df540614c11238a9e6765be3ae to your computer and use it in GitHub Desktop.
pyROOT_with_python3_Dockerfile

I wanted to compile cernroot on ubuntu with python3 bindings for ROOT (pyROOT).

This is what worked for me (Dockerfile)

Let’s go ahead and test it:

Build the docker:

mkdir pyROOT_docker
cd pyROOT_docker
wget https://gist.github.com/acidbourbon/48fdc0df540614c11238a9e6765be3ae/raw/cad9e530ac83b4fcab2323307146a5ef0ffeee49/Dockerfile
docker build -t pyROOT_docker .

Run the docker (with x11 support)

docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix \
--name pyROOT_docker -v $(pwd)/workdir:/workdir \
--rm -it --user $(id -u) pyROOT_docker /bin/bash

Test the installation inside the docker:

micha@5be8c924103b:/$ . /root-build/bin/thisroot.sh
micha@5be8c924103b:/$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.TBrowser()
<ROOT.TBrowser object ("Browser") at 0x35d8560>
>>>

... a TBrowser window opens ... win!

#---------------------------
FROM ubuntu:18.04
USER root
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install \
vim \
nano \
libgslcblas0 \
python3-numpy \
python3-scipy \
python3-matplotlib \
perl \
bc \
git \
liblapack3 \
libboost-all-dev \
gv ghostscript xterm x11-utils \
dialog \
python3-pip \
wget \
git dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev \
libxft-dev libxext-dev
RUN pip3 install --upgrade pip
RUN pip3 install pythondialog
RUN wget https://root.cern/download/root_v6.18.02.source.tar.gz && tar -zxvf root_v6.18.02.source.tar.gz && rm root_v6.18.02.source.tar.gz
RUN mkdir /root-build && cd /root-build; cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 ../root-6.18.02
RUN cd /root-build; make -j6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment