/
build_nature_stack.sh
59 lines (44 loc) · 1.71 KB
/
build_nature_stack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# Build OpenBLAS and clean up build dependencies
set -xe
mkdir /tmp/build
cd /tmp/build
apt-get -y update
apt-get -y install git-core build-essential gfortran python3-dev curl
echo '/opt/OpenBLAS/lib' > /etc/ld.so.conf.d/openblas.conf
curl https://raw.githubusercontent.com/ipython/docker-notebook/master/scipystack/numpy-site.cfg -o /tmp/numpy-site.cfg
curl https://raw.githubusercontent.com/ipython/docker-notebook/master/scipystack/scipy-site.cfg -o /tmp/scipy-site.cfg
# Build latest stable release from OpenBLAS from source
git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git
(cd OpenBLAS \
&& make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=32 \
&& make install)
# Rebuild ld cache, this assumes that:
# /etc/ld.so.conf.d/openblas.conf was installed by Dockerfile
# and that the libraries are in /opt/OpenBLAS/lib
ldconfig
# System dependencies
apt-get build-dep -y python3 python3-numpy python3-scipy python3-matplotlib cython3 python3-h5py
apt-get install -y build-essential python3-dev
git clone -q --branch=v1.9.0 git://github.com/numpy/numpy.git
cp /tmp/numpy-site.cfg numpy/site.cfg
git clone -q --branch=v0.14.0 git://github.com/scipy/scipy.git
cp /tmp/scipy-site.cfg scipy/site.cfg
curl https://bootstrap.pypa.io/get-pip.py | python3
PYTHONVER=3
PYTHON="python$PYTHONVER"
PIP="pip$PYTHONVER"
# Build NumPy and SciPy from source against OpenBLAS installed
(cd numpy && $PYTHON setup.py install)
(cd scipy && $PYTHON setup.py install)
# The rest of the SciPy Stack
$PIP install cython
$PIP install pandas scikit-learn scikit-image
$PIP install matplotlib
$PIP install seaborn
$PIP install sympy
# Reduce the image size
apt-get autoremove -y
apt-get clean -y
cd /
rm -rf /tmp/build