| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
from distutils.core import setup |
|---|
| 4 |
from distutils.command.build import build as _build |
|---|
| 5 |
import os |
|---|
| 6 |
|
|---|
| 7 |
class build(_build): |
|---|
| 8 |
"""Add nrnivmodl to the end of the build process.""" |
|---|
| 9 |
|
|---|
| 10 |
def run(self): |
|---|
| 11 |
_build.run(self) |
|---|
| 12 |
nrnivmodl = self.find_nrnivmodl() |
|---|
| 13 |
if nrnivmodl: |
|---|
| 14 |
print "nrnivmodl found at", nrnivmodl |
|---|
| 15 |
import subprocess |
|---|
| 16 |
p = subprocess.Popen(nrnivmodl, shell=True, stdin=subprocess.PIPE, |
|---|
| 17 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
|---|
| 18 |
close_fds=True, cwd=os.path.join(os.getcwd(),'build/lib/pyNN/hoc')) |
|---|
| 19 |
result = p.wait() |
|---|
| 20 |
|
|---|
| 21 |
if result != 0: |
|---|
| 22 |
errorMsg = p.stderr.readlines() |
|---|
| 23 |
print "Unable to compile NEURON extensions. Error message was:" |
|---|
| 24 |
print errorMsg |
|---|
| 25 |
else: |
|---|
| 26 |
print "Successfully compiled NEURON extensions." |
|---|
| 27 |
else: |
|---|
| 28 |
print "Unable to find nrnivmodl. It will not be possible to use the pyNN.neuron module." |
|---|
| 29 |
|
|---|
| 30 |
def find_nrnivmodl(self): |
|---|
| 31 |
"""Try to find the nrnivmodl executable.""" |
|---|
| 32 |
path = os.environ.get("PATH", "").split(os.pathsep) |
|---|
| 33 |
nrnivmodl = '' |
|---|
| 34 |
for dir_name in path: |
|---|
| 35 |
abs_name = os.path.abspath(os.path.normpath(os.path.join(dir_name, "nrnivmodl"))) |
|---|
| 36 |
if os.path.isfile(abs_name): |
|---|
| 37 |
nrnivmodl = abs_name |
|---|
| 38 |
break |
|---|
| 39 |
return nrnivmodl |
|---|
| 40 |
|
|---|
| 41 |
setup( |
|---|
| 42 |
name = "PyNN", |
|---|
| 43 |
version = "0.5.0alpha", |
|---|
| 44 |
package_dir={'pyNN': 'src'}, |
|---|
| 45 |
packages = ['pyNN','pyNN.nest2old','pyNN.nest2', 'pyNN.nest1','pyNN.pcsim','pyNN.neuron','pyNN.neuron2','pyNN.brian'], |
|---|
| 46 |
package_data = {'pyNN': ['hoc/*.hoc', 'hoc/*.mod']}, |
|---|
| 47 |
author = "The NeuralEnsemble Community", |
|---|
| 48 |
author_email = "pynn@neuralensemble.org", |
|---|
| 49 |
description = "A Python package for simulator-independent specification of neuronal network models", |
|---|
| 50 |
license = "CeCILL", |
|---|
| 51 |
keywords = "computational neuroscience simulation neuron nest pcsim neuroml", |
|---|
| 52 |
url = "http://neuralensemble.org/PyNN/", |
|---|
| 53 |
cmdclass = {'build': build}, |
|---|
| 54 |
) |
|---|
| 55 |
|
|---|