forked from NeuralEnsemble/PyNN
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
126 lines (115 loc) · 5.36 KB
/
setup.py
File metadata and controls
126 lines (115 loc) · 5.36 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
try:
from setuptools import setup
from setuptools.command.build_py import build_py as _build
tests_req = ["mpi4py", "scipy", "matplotlib", "Cheetah3", "h5py"]
except ImportError:
from distutils.core import setup
from distutils.command.build_py import build_py as _build
import os
import subprocess
def run_command(path, working_directory):
p = subprocess.Popen(path, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True,
cwd=working_directory)
stdout, stderr = p.communicate()
return p.returncode, stdout.split("\n")
class build(_build):
"""At the end of the build process, try to compile NEURON and NEST extensions."""
def run(self):
_build.run(self)
# try to compile NEURON extensions
nrnivmodl = self.find("nrnivmodl")
if nrnivmodl:
print("nrnivmodl found at", nrnivmodl)
result, stdout = run_command(nrnivmodl,
os.path.join(os.getcwd(), self.build_lib, 'pyNN/neuron/nmodl'))
# test if nrnivmodl was successful
if result != 0:
print("Unable to compile NEURON extensions. Output was:")
print(' '.join([''] + stdout)) # indent error msg for easy comprehension
else:
print("Successfully compiled NEURON extensions.")
else:
print("Unable to find nrnivmodl. It will not be possible to use the pyNN.neuron module.")
# try to compile NEST extensions
nest_config = self.find("nest-config")
if nest_config:
print("nest-config found at", nest_config)
nest_build_dir = os.path.join(os.getcwd(), self.build_lib, 'pyNN/nest/_build')
if not os.path.exists(nest_build_dir):
os.mkdir(nest_build_dir)
result, stdout = run_command("cmake -Dwith-nest={} ../extensions".format(nest_config),
nest_build_dir)
if result != 0:
print("Problem running cmake. Output was:")
print(' '.join([''] + stdout))
else:
result, stdout = run_command("make", nest_build_dir)
if result != 0:
print("Unable to compile NEST extensions. Output was:")
print(' '.join([''] + stdout))
else:
# should really move this to install stage
result, stdout = run_command("make install", nest_build_dir)
if result != 0:
print("Unable to install NEST extensions. Output was:")
print(' '.join([''] + stdout))
else:
print("Successfully compiled NEST extensions.")
def find(self, command):
"""Try to find an executable file."""
path = os.environ.get("PATH", "").split(os.pathsep)
cmd = ''
for dir_name in path:
abs_name = os.path.abspath(os.path.normpath(os.path.join(dir_name, command)))
if os.path.isfile(abs_name):
cmd = abs_name
break
return cmd
setup(
name="PyNN",
version="0.10.1.dev",
packages=['pyNN', 'pyNN.nest', 'pyNN.neuron',
'pyNN.brian2', 'pyNN.common', 'pyNN.mock', 'pyNN.neuroml',
'pyNN.recording', 'pyNN.standardmodels', 'pyNN.descriptions',
'pyNN.nest.standardmodels', 'pyNN.neuroml.standardmodels',
'pyNN.neuron.standardmodels',
'pyNN.brian2.standardmodels', 'pyNN.utility', 'pyNN.nineml',
'pyNN.serialization'],
package_data={'pyNN': ['neuron/nmodl/*.mod',
'nest/extensions/*.h',
'nest/extensions/*.cpp',
'nest/extensions/CMakeLists.txt',
'nest/extensions/sli/*.sli',
"descriptions/templates/*/*"]},
author="The PyNN team",
author_email="andrew.davison@unic.cnrs-gif.fr",
description="A Python package for simulator-independent specification of neuronal network models",
long_description=open("README.rst").read(),
license="CeCILL http://www.cecill.info",
keywords="computational neuroscience simulation neuron nest brian2 neuromorphic",
url="http://neuralensemble.org/PyNN/",
classifiers=['Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Science/Research',
'License :: Other/Proprietary License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Scientific/Engineering'],
cmdclass={'build_py': build},
install_requires=['numpy>=1.16.1', 'lazyarray>=0.5.0', 'neo>=0.10.0',
'quantities>=0.12.1'],
extras_require={
'examples': ['matplotlib', 'scipy'],
'plotting': ['matplotlib', 'scipy'],
'MPI': ['mpi4py'],
'sonata': ['h5py']
},
tests_require=tests_req
)