Skip to content

Commit 68e7b3c

Browse files
authored
Merge pull request #306 from openworm/development
Switch Dockerfile to use Python 3
2 parents 7cc8ec2 + b42f909 commit 68e7b3c

File tree

16 files changed

+183
-99
lines changed

16 files changed

+183
-99
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DS_Store
22
output/C2*
3-
/rebuild.sh
3+
/rebuild2.sh
44
/output/siminfo.py
55
/output/wor*

Dockerfile

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:16.04
1+
FROM ubuntu:18.04
22

33
LABEL maintainer="David Lung ([email protected]); Padraig Gleeson ([email protected])"
44

@@ -38,13 +38,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \
3838
g++ rpm libtool libncurses5-dev zlib1g-dev bison flex lsb-core \
3939
sudo xorg openbox x11-xserver-utils \
4040
libxext-dev libncurses-dev python-dev mercurial \
41-
freeglut3-dev libglu1-mesa-dev libglew-dev python-dev python-pip python-lxml python-numpy python-scipy python-tk \
41+
freeglut3-dev libglu1-mesa-dev libglew-dev python3-dev python3-pip python3-lxml python3-scipy python3-tk \
4242
kmod dkms linux-source linux-headers-generic \
4343
maven openjdk-8-jdk \
44-
python-setuptools python-yaml libnuma1 \
45-
openmpi-bin libopenmpi-dev \
44+
python3-setuptools python3-yaml libnuma1 \
45+
openmpi-bin libopenmpi-dev \
4646
libgl1-mesa-glx libgl1-mesa-dri libfreetype6-dev \
47-
libpng12-dev libxft-dev python-matplotlib xubuntu-desktop ffmpeg xvfb tmux
47+
libxft-dev python3-matplotlib unzip ffmpeg xvfb tmux
4848

4949
#RUN sudo pip install --upgrade pip
5050
#RUN sudo apt-get install nvidia-opencl-dev
@@ -66,36 +66,35 @@ RUN mkdir neuron && \
6666
git checkout 76c123b && \
6767
./build.sh && \
6868
./configure --prefix=`pwd` && \
69-
make && \
69+
make -j3 && \
7070
sudo make install && \
7171
cd ../nrn && \
7272
git checkout e0950a1 && \
7373
./build.sh && \
74-
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython=/usr/bin/python --with-paranrn && \
75-
make && \
74+
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython=/usr/bin/python3 --with-paranrn && \
75+
make -j3 && \
7676
sudo make install && \
7777
cd src/nrnpython && \
78-
sudo python setup.py install
78+
sudo python3 setup.py install
7979

8080

8181
################################################################################
8282
######## Install pyNeuroML for handling NeuroML network model
8383

8484
RUN git clone https://github.com/NeuroML/pyNeuroML.git && \
8585
cd pyNeuroML && \
86-
git checkout ow-0.9 && \
87-
sudo python setup.py install
86+
git checkout master && \
87+
sudo python3 setup.py install
8888

8989

9090
################################################################################
9191
######## Install PyOpenWorm
9292

93-
RUN pip install pyparsing==2.0.3 Jinja2==2.11.1 configparser==4.0.2 GitPython==3.0.7 gitdb2==2.0.6
9493
RUN git clone https://github.com/openworm/PyOpenWorm.git && \
9594
cd PyOpenWorm && \
9695
git checkout ow-0.9 && \
97-
sudo apt-get install -y python-cffi && \
98-
sudo python setup.py install && \
96+
sudo apt-get install -y python3-cffi && \
97+
sudo python3 setup.py install && \
9998
pow clone https://github.com/openworm/OpenWormData.git
10099

101100

@@ -104,17 +103,16 @@ RUN git clone https://github.com/openworm/PyOpenWorm.git && \
104103

105104
RUN git clone https://github.com/openworm/c302.git && \
106105
cd c302 && \
107-
git checkout ow-0.9 && \
108-
sudo python setup.py install
106+
git checkout ow-0.9.1 && \
107+
sudo python3 setup.py install
109108

110109

111110
################################################################################
112111
######## Install Sibernetic for the worm body model
113112

114113
RUN git clone https://github.com/openworm/sibernetic.git && \
115114
cd sibernetic && \
116-
# fixed to a specific branch
117-
git checkout ow-0.9
115+
git checkout ow-0.9.1 # fixed to a specific branch
118116

119117
RUN cp c302/pyopenworm.conf sibernetic/ # Temp step until PyOpenWorm can be run from any dir...
120118

@@ -155,15 +153,17 @@ RUN mkdir intel-opencl-tmp && \
155153
sudo rm -r intel-opencl-tmp
156154

157155
RUN sudo cp -R /opt/intel/opencl/include/CL /usr/include/ && \
158-
sudo apt install -y ocl-icd-opencl-dev
156+
sudo apt install -y ocl-icd-opencl-dev vim
159157
#sudo ln -s /opt/intel/opencl/libOpenCL.so.1 /usr/lib/libOpenCL.so
160158

161159

162160
################################################################################
163161
######## Build Sibernetic
164162

165163
RUN cd sibernetic && \
166-
make clean && make all
164+
sed -i -e "s/lpython2.7/lpython3.6m/g" makefile && \
165+
sed -i -e "s/n2.7/n3.6/g" makefile && \
166+
make clean && make all # Use python 3 libs
167167

168168
# intel i5, hd 5500, linux 4.15.0-39-generic
169169
# ./Release/Sibernetic -f worm -no_g device=CPU 190ms
@@ -179,3 +179,12 @@ make clean && make all
179179
## sudo apt-get update
180180
## sudo apt-get install -y cuda-drivers
181181
# ./Release/Sibernetic -f worm -no_g device=GPU 37ms
182+
183+
184+
185+
#### TODO: check that this is the best way to switch to py3...
186+
RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
187+
188+
RUN echo '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"' >> ~/.bashrc
189+
190+
RUN echo "Built the OpenWorm Docker image!"
Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:16.04
22

3-
MAINTAINER David Lung "[email protected]"
3+
# For generating/running a Dockerfile image based on Python 2
4+
# Note: Python 2 is no longer officially supported and this Docker image will
5+
# probably stop working eventually...
46

7+
LABEL maintainer="David Lung ([email protected]); Padraig Gleeson ([email protected])"
58

69
ARG INTEL_SDK_VERSION=2017_7.0.0.2511_x64
710

@@ -31,38 +34,23 @@ ENV DEBIAN_FRONTEND noninteractive # TODO: change
3134
#RUN useradd -ms /bin/bash $USER
3235

3336

37+
################################################################################
38+
######## Update/install essential libraries
39+
3440
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \
35-
wget \
36-
nano \
37-
htop \
38-
build-essential \
39-
make \
40-
git \
41-
automake \
42-
autoconf \
43-
g++ \
44-
rpm \
45-
libtool \
46-
libncurses5-dev \
47-
zlib1g-dev \
48-
bison \
49-
flex \
50-
lsb-core \
51-
sudo \
52-
xorg \
53-
openbox \
54-
x11-xserver-utils \
55-
libxext-dev libncurses-dev python3-dev mercurial \
56-
freeglut3-dev libglu1-mesa-dev libglew-dev python3-dev python3-pip python3-lxml python3-numpy python3-scipy python3-tk \
57-
kmod dkms \
58-
linux-source linux-headers-generic \
41+
wget nano htop build-essential make git automake autoconf \
42+
g++ rpm libtool libncurses5-dev zlib1g-dev bison flex lsb-core \
43+
sudo xorg openbox x11-xserver-utils \
44+
libxext-dev libncurses-dev python-dev mercurial \
45+
freeglut3-dev libglu1-mesa-dev libglew-dev python-dev python-pip python-lxml python-numpy python-scipy python-tk \
46+
kmod dkms linux-source linux-headers-generic \
5947
maven openjdk-8-jdk \
60-
python3-setuptools python3-yaml libnuma1 \
61-
openmpi-bin libopenmpi-dev \
62-
libgl1-mesa-glx libgl1-mesa-dri libfreetype6-dev \
63-
libxft-dev python3-matplotlib xubuntu-desktop ffmpeg xvfb tmux
64-
48+
python-setuptools python-yaml libnuma1 \
49+
openmpi-bin libopenmpi-dev \
50+
libgl1-mesa-glx libgl1-mesa-dri libfreetype6-dev \
51+
libpng12-dev libxft-dev python-matplotlib unzip ffmpeg xvfb tmux
6552

53+
#RUN sudo pip install --upgrade pip
6654
#RUN sudo apt-get install nvidia-opencl-dev
6755

6856
RUN sudo usermod -a -G video $USER
@@ -71,6 +59,9 @@ USER $USER
7159
ENV HOME /home/$USER
7260
WORKDIR $HOME
7361

62+
################################################################################
63+
######## Install NEURON simulator
64+
7465
RUN mkdir neuron && \
7566
cd neuron && \
7667
git clone https://github.com/nrnhines/iv.git && \
@@ -84,44 +75,57 @@ RUN mkdir neuron && \
8475
cd ../nrn && \
8576
git checkout e0950a1 && \
8677
./build.sh && \
87-
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython=/usr/bin/python3 --with-paranrn && \
78+
./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-nrnpython=/usr/bin/python --with-paranrn && \
8879
make -j3 && \
8980
sudo make install && \
9081
cd src/nrnpython && \
91-
sudo python3 setup.py install
82+
sudo python setup.py install
83+
84+
85+
################################################################################
86+
######## Install pyNeuroML for handling NeuroML network model
9287

93-
88+
RUN pip install cachetools==0.8.0
9489
RUN git clone https://github.com/NeuroML/pyNeuroML.git && \
9590
cd pyNeuroML && \
96-
git checkout ow-0.9 && \
97-
sudo python3 setup.py install
91+
git checkout master && \
92+
sudo python setup.py install
9893

99-
RUN pip3 install pyparsing==2.0.3
100-
RUN pip3 install Jinja2==2.11.1
101-
RUN pip3 install configparser==4.0.2
94+
95+
################################################################################
96+
######## Install PyOpenWorm
97+
98+
RUN pip install pyparsing==2.0.3 Jinja2==2.11.1 configparser==4.0.2 GitPython==3.0.7 gitdb2==2.0.6 numpydoc==0.9.2 Sphinx==1.8.3 future==0.18.2 setuptools==41.5.1
10299
RUN git clone https://github.com/openworm/PyOpenWorm.git && \
103100
cd PyOpenWorm && \
104101
git checkout ow-0.9 && \
105-
sudo apt-get install -y python3-cffi && \
106-
sudo python3 setup.py install && \
102+
sudo apt-get install -y python-cffi && \
103+
sudo python setup.py install && \
107104
pow clone https://github.com/openworm/OpenWormData.git
108105

109-
###############################RUN pyconfif
110106

111-
RUN git clone https://github.com/openworm/c302.git && \
107+
################################################################################
108+
######## Install c302 for building neuronal network models
109+
110+
RUN git clone https://github.com/openworm/c302.git && \
112111
cd c302 && \
113-
git checkout ow-0.9 && \
114-
sudo python3 setup.py install
112+
git checkout ow-0.9.1 && \
113+
sudo python setup.py install
114+
115115

116+
################################################################################
117+
######## Install Sibernetic for the worm body model
116118

117-
RUN git clone https://github.com/pgleeson/sibernetic.git && \
119+
RUN git clone https://github.com/openworm/sibernetic.git && \
118120
cd sibernetic && \
119-
# fixed to a specific commit in development branch:
120-
# https://github.com/openworm/sibernetic/commit/3eb9914db040fff852cba76ef8f4f39d0bed3294
121-
git checkout test_dev
121+
git checkout ow-0.9.1 # fixed to a specific branch
122122

123123
RUN cp c302/pyopenworm.conf sibernetic/ # Temp step until PyOpenWorm can be run from any dir...
124124

125+
126+
################################################################################
127+
######## Set some paths//environment variables
128+
125129
ENV JNML_HOME=$HOME/jNeuroML
126130
ENV PATH=$PATH:$JNML_HOME
127131
ENV IV=$HOME/neuron/iv
@@ -138,6 +142,9 @@ COPY ./master_openworm.py $HOME/master_openworm.py
138142
RUN sudo chown $USER:$USER $HOME/master_openworm.py
139143

140144

145+
################################################################################
146+
######## Install Intel OpenCL libraries needed for Sibernetic
147+
141148
RUN mkdir intel-opencl-tmp && \
142149
cd intel-opencl-tmp && \
143150
mkdir intel-opencl && \
@@ -155,9 +162,12 @@ RUN sudo cp -R /opt/intel/opencl/include/CL /usr/include/ && \
155162
sudo apt install -y ocl-icd-opencl-dev vim
156163
#sudo ln -s /opt/intel/opencl/libOpenCL.so.1 /usr/lib/libOpenCL.so
157164

165+
166+
################################################################################
167+
######## Build Sibernetic
168+
158169
RUN cd sibernetic && \
159-
sed -i -e "s/n2.7/n3.6/g" makefile # Use python 3 libs && \
160-
make clean && make all
170+
make clean && make all
161171

162172
# intel i5, hd 5500, linux 4.15.0-39-generic
163173
# ./Release/Sibernetic -f worm -no_g device=CPU 190ms
@@ -175,13 +185,6 @@ RUN cd sibernetic && \
175185
# ./Release/Sibernetic -f worm -no_g device=GPU 37ms
176186

177187

178-
179-
180-
181-
182-
#### TODO: check that this is the best way to switch to py3...
183-
RUN sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
184-
185188
RUN echo '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alt"' >> ~/.bashrc
186189

187-
RUN echo "Built the OpenWorm Docker image!"
190+
RUN echo "Built the OpenWorm Docker image!"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2011 Individual Authors of code
1+
Copyright (c) 2012-2021 Individual Authors of code
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
docker build -t "openworm/openworm:0.9" .
1+
docker build -t "openworm/openworm:0.9.1" .

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker build "$@" -t "openworm/openworm:0.9" .
3+
docker build "$@" -t "openworm/openworm:0.9.1" .

build2.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# For generating/running a Dockerfile image based on Python 2
4+
# Note: Python 2 is no longer officially supported and this Docker image will
5+
# probably stop working eventually...
6+
7+
docker build "$@" -t "openworm/openworm:0.9.1_py2" -f Dockerfile2 .

build3.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

master_openworm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import matplotlib
44
matplotlib.use('Agg')
55
import shutil
6-
from subprocess import call, Popen, PIPE, check_output
6+
from subprocess import Popen, PIPE, check_output
77
import os
88
import pwd
99
import shlex
@@ -12,9 +12,9 @@
1212
import glob
1313
import math
1414

15-
print("***************************")
16-
print("OpenWorm Master Script v0.9")
17-
print("***************************")
15+
print("*****************************")
16+
print("OpenWorm Master Script v0.9.1")
17+
print("*****************************")
1818
print("")
1919
print("This script attempts to run a full pass through the OpenWorm scientific libraries.")
2020
print("This depends on several other repositories being loaded to work and presumes it is running in a preloaded Docker instance.")
@@ -100,7 +100,7 @@ def execute_with_realtime_output(command, directory, env=None):
100100

101101

102102
try:
103-
if pwd.getpwuid(os.stat(OW_OUT_DIR).st_uid).pw_name != os.environ['USER']:
103+
if os.access(OW_OUT_DIR, os.W_OK) is not True:
104104
os.system('sudo chown -R %s:%s %s' % (os.environ['USER'], os.environ['USER'], OW_OUT_DIR))
105105
except:
106106
print("Unexpected error: %s" % sys.exc_info()[0])
@@ -215,7 +215,7 @@ def execute_with_realtime_output(command, directory, env=None):
215215

216216
# Remove black frames at the beginning of the recorded video
217217
command = "ffmpeg -i %s/%s -vf blackdetect=d=0:pic_th=0.70:pix_th=0.10 -an -f null - 2>&1 | grep blackdetect" % (new_sim_out, sibernetic_movie_name)
218-
outstr = check_output(command, shell=True)
218+
outstr = str(check_output(command, shell=True).decode('utf-8'))
219219
outstr = outstr.split('\n')
220220

221221
black_start = 0.0

rebuild.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build "$@" -t "openworm/openworm:0.9.1" --no-cache .

0 commit comments

Comments
 (0)