https://github.com/davidcsterratt/KappaNEURON
Tip revision: deb64f99a184f609e9a8a9549bea23f52a0cd70b authored by David C Sterratt on 23 February 2021, 18:54:02 UTC
Moved to .sh extension
Moved to .sh extension
Tip revision: deb64f9
INSTALL-neuron
#!/bin/bash
# Script to checkout and install branch of Neuron
# Branches have names such as "Release 7.4"
# By default, the working version is installed.
NCPU=4
version=
DATE=
PREFIX=${HOME}/nrn
REPO=https://www.github.com/neuronsimulator
OPTIND=1
while getopts "d:c:v:" opt; do
case "$opt" in
v) version=$OPTARG
;;
c) commitid=$OPTARG
;;
d) DATE=$OPTARG
;;
esac
done
if [ "x${commitid}" != "x" ]; then
NRNPREFIX=${PREFIX}/${commitid}
echo "Commit \"$commitid\" will be checked out.."
else
## Defaults. Set version to version known to work.
if [ "x$version" == "x" ] && [ "x$DATE" == "x" ]; then
version="7.4"
fi
if [ "x$version" == "x" ] || [ "x$version" == "xmaster"]; then
branch=master
if [ "x${DATE}" == "x" ]; then
NRNPREFIX=${PREFIX}/${branch}
else
NRNPREFIX=${PREFIX}/${branch}-${DATE}
fi
else
branch="${version}"
if [ "x${DATE}" == "x" ]; then
NRNPREFIX=${PREFIX}/${version}
else
NRNPREFIX=${PREFIX}/${version}-${DATE}
fi
fi
echo "Branch \"$branch\" will be checked out.."
fi
echo "...and installed in ${NRNPREFIX}"
function installpkg {
echo -n "checking for $1 ... "
if [ -e $1 ]; then
echo "present"
else
if [ -x "/usr/bin/apt-get" ]; then
echo
sudo apt-get install $2
else
echo "perhaps not present - check package equivalent to Debian $2 is installed"
fi
fi
}
installpkg /usr/bin/bison bison
installpkg /usr/bin/flex flex
installpkg /usr/bin/git git
installpkg /usr/bin/gcc-5 gcc-5 build-essential
installpkg /usr/bin/g++-5 g++-5
installpkg /usr/bin/aclocal automake
installpkg /usr/bin/libtoolize libtool
installpkg /usr/include/X11/Xlib.h libx11-dev
installpkg /usr/include/X11/extensions/Xext.h libxext-dev
installpkg /usr/include/python2.7/Python.h libpython2.7-dev
installpkg /usr/include/ncurses.h ncurses-dev
installpkg /usr/lib/python2.7/dist-packages/scipy/version.py python-scipy
installpkg /usr/lib/python2.7/dist-packages/matplotlib/__init__.py python-matplotlib
mkdir neuron-build
cd neuron-build
# Install neuron
if [ -d iv ] ; then
cd iv
git pull
cd ..
else
git clone ${REPO}/iv # skip this if you don't want the GUI
fi
if [ -d nrn ] ; then
cd nrn
git pull
cd ..
else
git clone ${REPO}/nrn
fi
cd iv/
./build.sh
./configure --prefix=$NRNPREFIX/iv
make -j ${NCPU}
make install
cd ../nrn
if [ "x${commitid}" != "x" ]; then
git checkout "${commitid}"
else
if [ "x${DATE}" != "x" ]; then
git checkout \'${branch}@{${DATE} 00:00:00}\'
else
git checkout "${branch}"
fi
fi
if [ -x hg2nrnversion_h.sh ]; then
wget -p https://raw.githubusercontent.com/neuronsimulator/nrn/fc3ff7d10d62e537ab2e286066891e74dcfe51a8/git2nrnversion_h.sh
head -10 hg2nrnversion_h.sh > git-hg2nrnversion_h.sh
tail -21 git2nrnversion_h.sh >> git-hg2nrnversion_h.sh
perl -i -p -e 's/GIT_/HG_/;' git-hg2nrnversion_h.sh
chmod u+x git-hg2nrnversion_h.sh
./git-hg2nrnversion_h.sh > src/nrnoc/nrnversion.h
echo "#define HG_LOCAL \"?\"" >> src/nrnoc/nrnversion.h
echo "#define HG_TAG \"\"" >> src/nrnoc/nrnversion.h
fi
./build.sh
CC=gcc-5 CXX=g++-5 CFLAGS="-DNPY_NO_DEPRECATED_API=1 -DNPY_1_7_API_VERSION=1" CXXFLAGS="-DNPY_NO_DEPRECATED_API=1 -DNPY_1_7_API_VERSION=1" ./configure --prefix=$NRNPREFIX/nrn --with-iv=$NRNPREFIX/iv --with-nrnpython=/usr/bin/python2.7
make -j ${NCPU}
make install
cd ..
# Python packages are installed in ${NRNPREFIX}/lib/python
echo "Branch \"$branch\" (Date: ${DATE}) has been installed in ${NRNPREFIX}"
## Test
${NRNPREFIX}/nrn/x86_64/bin/nrngui
echo "To test python"
echo "--------------"
echo
echo "1. Add the neuron package to your PYTHONPATH:"
echo " export PYTHONPATH=${NRNPREFIX}/nrn/lib/python/:\$PYTHONPATH"
echo
echo "2. Try the following:"
echo
echo " python2.7"
echo " import neuron"
echo " import neuron.rxd.rxd"
echo
echo " export PYTHONPATH=${NRNPREFIX}/nrn/lib/python/:\$PYTHONPATH"