Skip to content

Instantly share code, notes, and snippets.

@tarelli
Created May 6, 2015 15:05
Show Gist options
  • Save tarelli/6d23d9fa33eca5b6d253 to your computer and use it in GitHub Desktop.
Save tarelli/6d23d9fa33eca5b6d253 to your computer and use it in GitHub Desktop.
Setup NEURON
import os
import sys
from subprocess import check_output as co
from distutils.core import run_setup
class working_dir(object):
"""Context manager for changing the current working directory"""
def __init__(self, newPath):
self.newPath = newPath
def __enter__(self):
self.savedPath = os.getcwd()
os.chdir(self.newPath)
def __exit__(self, etype, value, traceback):
os.chdir(self.savedPath)
nrnpath = '/home/virgo/neuron'
os.mkdir(nrnpath)
with working_dir(nrnpath):
print co(['wget', 'http://www.neuron.yale.edu/ftp/neuron/versions/v7.3/nrn-7.3.tar.gz'])
print co(['tar', 'xzvf', 'nrn-7.3.tar.gz'])
print co(['mv', 'nrn-7.3', 'nrn'])
os.chdir('nrn')
path = os.getcwd()
pyexec = sys.executable
co(["./configure --prefix=%s --without-iv --with-nrnpython=%s"%(path,pyexec)], shell=True)
print co(['make'])
print co(['make', 'install'])
os.chdir('src/nrnpython')
run_setup('./setup.py', ['install'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment