Skip to content

Instantly share code, notes, and snippets.

@Helveg
Created March 20, 2021 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Helveg/e23974b17df0f79ab3cedc911e08966e to your computer and use it in GitHub Desktop.
Save Helveg/e23974b17df0f79ab3cedc911e08966e to your computer and use it in GitHub Desktop.
NEURON pyenv install script
#!/bin/bash
# https://github.com/neuronsimulator/nrn/issues/409#issuecomment-576953060
#
# If first arg is "clean" then remove the neuron module
# from site-packages and exit.
#
# If first arg is "test" then run "python -c 'import neuron; neuron.test()'"
#
# If first arg is "install" then build and install with support for all
# subsequent pyenv version names.
# The "pyenv versions" that we want to work with.
versions=${@:2}
set -e
clean=
test=
if test "$1" = "clean" ; then
clean="yes"
fi
if test "$1" = "test" ; then
test="yes"
fi
set PATH="$HOME/.pyenv/bin:$PATH"
export PATH
which pyenv
#just in case
unset PYTHONPATH
unset NEURONHOME
pythons=""
eval "$(pyenv init -)"
for i in $versions ; do
pyenv shell $i
python=`pyenv which python`
if test "$test" = "yes" ; then
echo "testing $i"
python -c 'import neuron; neuron.test()'
fi
pyenv shell --unset
pythons="${pythons}${python};"
pydir=`dirname $python`
pydir=`realpath $pydir/..`
sitepack=`find $pydir -name site-packages`
if test "$clean" = "yes" ; then
echo "cleaning $sitepack"
if test -d "$sitepack" ; then
(cd $sitepack ; rm -f -r neuron NEURON*)
else
echo "could not find site-packages for $python"
fi
fi
done
if test "$clean" = "yes" ; then
echo "cleaned $versions"
exit 0
fi
if test "$test" = "yes"; then
echo "tested $versions"
exit 0
fi
echo $pythons
if [ -d "build" ]; then rm -rf build fi
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=install \
-DNRN_ENABLE_INTERVIEWS=OFF \
-DNRN_ENABLE_CORENEURON=OFF \
-DNRN_MODULE_INSTALL_OPTIONS="" \
-DNRN_ENABLE_PYTHON_DYNAMIC=ON \
-DNRN_PYTHON_DYNAMIC="$pythons"
make -j
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment