install.sh 3.89 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
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
11
12
13
14
15
     brew update
  else
     ## xcode-select --install will need a GUI :/
     /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  fi
16

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
17
  brew install swi-prolog gsl gnuplot graphviz pkg-config ppl
18
  brew tap brewsci/science
19
  brew install libsbml nusmv
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
20
  brew upgrade
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
21
  brew cleanup
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
22
elif [[ -r /etc/debian_version ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
23
then
SOLIMAN Sylvain's avatar
typos    
SOLIMAN Sylvain committed
24
  conda_arch="Linux"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
25
  ### Ubuntu or Debian
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
26

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
27
  sudo apt-get -qy update
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
28
  sudo apt-get -qy install lsb-release curl gcc g++ make pkg-config libgsl0-dev gnuplot libppl-dev graphviz-dev git
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
29

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
30
  if [[ $(lsb_release -sc) == "xenial" ]]
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
31
  then
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
32
    sudo apt-get -qy install swi-prolog libsbml5-dev
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
33
34
35
36
37
38
39
40
41
42
43
44
45
  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
46
      sudo apt-get -qy install libreadline-dev libgmp-dev
47
48
49
50
51
      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
52
53
54
55
      pushd swipl-7.2.3
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
56
57
58
59
      cd packages
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
60
61
62
      popd
    fi

63
    if ! pkg-config --atleast-version 5.11.4 libsbml
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
64
65
66
    then
      # Compiling libSBML from source, expecting that libSBML should
      # be packaged in the next releases of Ubuntu
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
67
      sudo apt-get -qy install libxml2-dev
68
69
70
71
72
      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
73
      pushd libsbml-5.13.0
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
74
75
76
      ./configure
      make
      sudo make install
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
77
      sudo ldconfig /usr/local/lib/
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
78
79
80
81
82
83
      popd
    fi
  fi

  if ! hash NuSMV 2>/dev/null
  then
Thierry Martinez's avatar
Thierry Martinez committed
84
    if [[ $(uname -i) == "x86_64" ]]
85
    then
Thierry Martinez's avatar
Thierry Martinez committed
86
87
88
89
90
91
92
93
      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
94
    fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
95
    pushd /usr/local
Thierry Martinez's avatar
Thierry Martinez committed
96
    sudo tar --strip-components 1 -xf $(dirs -l +1)/$nusmv_archive
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
97
98
99
100
101
102
103
104
    popd
  fi
else
  echo "Automatic install not available, feel free to use the source of this script."
  exit 1
fi

### Jupyter
105
106
if hash pip3 2>/dev/null
then
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
107
  pip3 install -U jupyter
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
108
else
109
110
  if hash conda 2>/dev/null
  then
111
    # conda update conda
Thierry Martinez's avatar
Thierry Martinez committed
112
    conda install -y jupyter
113
    # conda update -y jupyter
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
114
  else
Thierry Martinez's avatar
Thierry Martinez committed
115
116
    if [[ "$conda_arch" == "Linux" ]]
    then
117
      sudo apt-get -qy install python3-pip
Thierry Martinez's avatar
Thierry Martinez committed
118
119
120
121
122
123
124
125
126
127
128
129
      pip3 install -U jupyter
    else
      # 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}
      conda install -y jupyter
      conda update -y jupyter
    fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
130
  fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
131
fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
132

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
133
134
135
### trust all our notebooks
find . -name '*.ipynb' -print0 | xargs -0 jupyter trust

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
136
make clean && make
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
137

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
138
### biocham for jupyter
139
140
if ! hash biocham 2>/dev/null
then
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
141
142
  echo
  echo "##########"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
143
  echo "export PATH=$(pwd):\${PATH}" >> ${HOME}/.profile
144
  echo "Don't forget to source ~/.profile or to manually export PATH=$(pwd):\${PATH}"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
145
  echo "and if necessary export PATH=\${HOME}/miniconda3/bin:\${PATH}"
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
146
fi