install.sh 5.15 KB
Newer Older
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
1
#!/bin/bash
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
2
set -ue
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
3

SOLIMAN Sylvain's avatar
typos    
SOLIMAN Sylvain committed
4
if [[ $(uname -s) == "Darwin" ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
5
then
SOLIMAN Sylvain's avatar
typos    
SOLIMAN Sylvain committed
6
  conda_arch="MacOSX"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
7
8
  ### homebrew

9
10
  if hash brew 2>/dev/null
  then
11
    echo "Using existing homebrew…"
jog39's avatar
jog39 committed
12
    brew update
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
13
  else
14
    echo "Installing homebrew…"
jog39's avatar
jog39 committed
15
16
    ## xcode-select --install will need a GUI :/
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
17
  fi
18

19
20
21
22
23
24
25
26
27
  # https://stackoverflow.com/questions/43619480/upgrade-or-install-a-homebrew-formula
  function install_or_upgrade {
    if brew ls --versions "$1" >/dev/null; then
        HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade "$1"
    else
        HOMEBREW_NO_AUTO_UPDATE=1 brew install "$1"
    fi
  }

28
  brew tap brewsci/science
29
30
31
32
33
  brewlings='swi-prolog gsl gnuplot graphviz pkg-config ppl libsbml nusmv node'
  for brewling in $brewlings ; do
    install_or_upgrade "$brewling"
  done

34
  release=
35

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
36
elif [[ -r /etc/debian_version ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
37
then
SOLIMAN Sylvain's avatar
typos    
SOLIMAN Sylvain committed
38
  conda_arch="Linux"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
39
  ### Ubuntu or Debian
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
40

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
41
  sudo apt-get -qy update
42
  sudo apt-get -qy install lsb-release curl gcc g++ make pkg-config libgsl0-dev gnuplot libppl-dev graphviz-dev git nodejs npm
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
43

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
44
45
46
  release=$(lsb_release -sc)

  if [[ $release == "xenial" || $release == "bionic" ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
47
  then
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
48
    sudo apt-get -qy install swi-prolog libsbml5-dev
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
49
    if [[ $release == "bionic" ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
50
51
52
    then
      sudo apt-get -qy install zlib1g-dev
    fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
53
54
55
56
57
58
59
60
61
62
63
64
65
  else
    if ! swipl -g '
      call_cleanup(
        (
          current_prolog_flag(version, Version),
          Version >= 70203,
          halt(0)
        ),
        halt(1)
      )'
    then
      # Compiling swi-prolog from source, expecting that a newer version of
      # swi-prolog should be packaged in the next releases of Ubuntu
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
66
      sudo apt-get -qy install libreadline-dev libgmp-dev
67
68
69
70
71
      if [[ ! -d swipl-7.2.3 ]]
      then
        curl -fsSLO http://www.swi-prolog.org/download/stable/src/swipl-7.2.3.tar.gz
        tar -xf swipl-7.2.3.tar.gz
      fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
72
73
74
75
      pushd swipl-7.2.3
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
76
77
78
79
      cd packages
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
80
81
82
      popd
    fi

83
    if ! pkg-config --atleast-version 5.11.4 libsbml
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
84
85
86
    then
      # Compiling libSBML from source, expecting that libSBML should
      # be packaged in the next releases of Ubuntu
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
87
      sudo apt-get -qy install libxml2-dev
88
89
90
91
92
      if [[ ! -d libsbml-5.13.0 ]]
      then
        curl -fsSLO http://downloads.sourceforge.net/project/sbml/libsbml/5.13.0/stable/libSBML-5.13.0-core-src.tar.gz
        tar -xf libSBML-5.13.0-core-src.tar.gz
      fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
93
      pushd libsbml-5.13.0
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
94
95
96
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
97
      sudo ldconfig /usr/local/lib/
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
98
99
100
101
102
103
      popd
    fi
  fi

  if ! hash NuSMV 2>/dev/null
  then
Thierry Martinez's avatar
Thierry Martinez committed
104
    if [[ $(uname -i) == "x86_64" ]]
105
    then
Thierry Martinez's avatar
Thierry Martinez committed
106
107
108
109
110
111
112
113
      nusmv_url=http://nusmv.fbk.eu/distrib/NuSMV-2.6.0-linux64.tar.gz
    else
      nusmv_url=http://nusmv.fbk.eu/distrib/NuSMV-2.6.0-linux32.tar.gz
    fi
    nusmv_archive=${nusmv_url##*/}
    if [[ ! -r $nusmv_archive ]]
    then
      curl -fsSLO $nusmv_url
114
    fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
115
    pushd /usr/local
Thierry Martinez's avatar
Thierry Martinez committed
116
    sudo tar --strip-components 1 -xf $(dirs -l +1)/$nusmv_archive
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
117
118
119
120
121
122
123
    popd
  fi
else
  echo "Automatic install not available, feel free to use the source of this script."
  exit 1
fi

FAGES Francois's avatar
FAGES Francois committed
124
### Glucose
125
126
127
128
129
130
131
132
if [[ ! -f /usr/local/bin/glucose.py ]] ; then
  echo "Copying biocham's glucose.py to /usr/local/bin/"
  if [[ "$conda_arch" == "Linux" ]]
  then
    sudo cp glucose.py /usr/local/bin
  else
    cp glucose.py /usr/local/bin
  fi
BARGAIN Orianne's avatar
BARGAIN Orianne committed
133
134
fi

135
136
### Jupyter and python-sat
packages='python-sat jupyter bokeh ipywidgets'
137
if python3 -m pip --version 2>/dev/null
138
then
139
  echo "Using existing pip for python3…"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
140
else
141
  if hash conda 2>/dev/null
142
  then
143
    echo "Using existing conda install to get pip…"
144
    conda install -y pip
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
145
  else
146
    if [[ "$conda_arch" == "Linux" ]]
Thierry Martinez's avatar
Thierry Martinez committed
147
    then
148
      echo "Using apt to get python3-pip…"
149
150
      sudo apt-get -qy install python3-pip
    else
151
      echo "Installing miniconda3…"
152
153
154
155
156
157
158
      # Note that miniconda is available through brew cask, but to avoid adding
      # brew cask if not necessary, we just do without
      curl -fsSLO https://repo.continuum.io/miniconda/Miniconda3-latest-${conda_arch}-x86_64.sh
      chmod a+x Miniconda3-latest-${conda_arch}-x86_64.sh
      ./Miniconda3-latest-${conda_arch}-x86_64.sh -b -p ${HOME}/miniconda3
      echo 'export PATH=${HOME}/miniconda3/bin:${PATH}' >> ${HOME}/.profile
      export PATH=${HOME}/miniconda3/bin:${PATH}
159
      conda install -y pip
Thierry Martinez's avatar
Thierry Martinez committed
160
    fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
161
  fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
162
fi
163
164
echo "installing python packages ($packages)…"
python3 -m pip install -U $packages
165
jupyter nbextension enable --py widgetsnbextension
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
166

167
### trust all our notebooks but make them read-only
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
168
find . -name '*.ipynb' -print0 | xargs -0 jupyter trust
169
find . -name '*.ipynb' -print0 | xargs -0 chmod a-w
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
170

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
171
### install ipywidgets and bokeh extensions for jupyterlab
172
173
# jupyter labextension install @jupyter-widgets/jupyterlab-manager
# jupyter labextension install jupyterlab_bokeh
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
174

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
175
make clean && make
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
176

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
177
### biocham for jupyter
178
179
if ! hash biocham 2>/dev/null
then
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
180
181
  echo
  echo "##########"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
182
  echo "export PATH=$(pwd):\${PATH}" >> ${HOME}/.profile
183
  echo "Don't forget to source ~/.profile or to manually export PATH=$(pwd):\${PATH}"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
184
  echo "and if necessary export PATH=\${HOME}/miniconda3/bin:\${PATH}"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
185
fi