forked from GrossfieldLab/loos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conda_build.sh
executable file
·78 lines (67 loc) · 2.33 KB
/
conda_build.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# This file is part of LOOS.
#
# LOOS (Lightweight Object-Oriented Structure library)
# Copyright (c) 2013, Tod D. Romo
# Department of Biochemistry and Biophysics
# School of Medicine & Dentistry, University of Rochester
#
# This package (LOOS) is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation under version 3 of the License.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Alan Grossfield, University of Rochester, 12/6/2019
# USAGE: ./conda_build.sh ENVNAME
# will create conda environment ENVNAME if it doesn't exist, or install
# packages into ENVNAME if it already exists, then run scons to build
# LOOS. By default, it runs scons with 4 compile processes, but if you
# want to change that number (e.g. to 8 or 1), you can supply that as a
# second argument, e.g.
# ./conda_build.sh ENVNAME 8
envname=$1
numprocs=$2
platform=`uname`
echo "Setting channel priority to strict"
conda config --set channel_priority strict
packages="python=3 swig scons numpy scipy boost openblas libnetcdf lapack compilers eigen"
# does this env exist (there must be a smarter way to do this)
envs=$(conda env list | awk '{print $1}' )
for i in $envs; do
if [ "$i" = "$envname" ]; then
found=1
break
fi
done
if [ -z $found ]; then
echo "Creating conda environment $envname"
conda create -n $envname -c conda-forge $packages
else
echo "Installing into existing environment $envname"
conda install -c conda-forge $packages
fi
echo "Activating environment $envname"
CONDA_BASE=$(conda info --base)
source $CONDA_BASE/etc/profile.d/conda.sh
conda activate $envname
if [ "$platform" = "Linux" ]; then
export CXX=`which g++`
elif [ "$platform" = 'Darwin' ]; then
export CXX=`which clang++`
else
echo "Unknown platform $platform, assuming g++"
export CXX=`which g++`
fi
echo "CXX set to $CXX"
if [ $2 ]; then
scons -j$numprocs
else
scons -j4
fi