Skip to content

Commit f692206

Browse files
authored
Merge pull request #777 from apdavison/pyproject.toml
Switch to pyproject.toml
2 parents 8cf55f1 + c923665 commit f692206

File tree

10 files changed

+212
-198
lines changed

10 files changed

+212
-198
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ include pyNN/nest/extensions/*.cpp
44
include pyNN/nest/extensions/CMakeLists.txt
55
include pyNN/nest/extensions/sli/*
66
include pyNN/descriptions/templates/*/*.txt
7-
include test/parameters/*
87
include test/system/*.py
98
include test/system/scenarios/*.py
109
include test/unittests/*.py

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class MockNESTModule(mock.Mock):
7676
# built documents.
7777
#
7878
# The short X.Y version.
79-
version = '0.10'
79+
version = '0.11'
8080
# The full version, including alpha/beta/rc tags.
81-
release = '0.10.2.dev'
81+
release = '0.11.0.dev'
8282

8383
# The language for content autogenerated by Sphinx. Refer to documentation
8484
# for a list of supported languages.

doc/developers/contributing.txt

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ To work on the development version::
4343

4444
$ git checkout master
4545

46-
To work on the latest stable release (for bug-fixes)::
47-
48-
$ git checkout --track origin/0.8
49-
5046
To keep your PyNN repository up-to-date with respect to the official
5147
repository, add it as a remote::
5248

@@ -62,12 +58,7 @@ To get PyNN onto your :envvar:`PYTHONPATH` there are many options, such as:
6258
* pip editable mode (`pip install -e /path/to/PyNN`)
6359
* creating a symbolic link named :file:`pyNN` from somewhere that is already
6460
on your :envvar:`PYTHONPATH`, such as the :file:`site-packages` directory,
65-
to the :file:`pyNN_trunk/pyNN` directory.
66-
67-
If you are developing with NEURON, don't forget to compile the NMODL files in
68-
:file:`pyNN/neuron/nmodl` by running :command:`nrnivmodl`, and to recompile any time
69-
you modify any of them.
70-
61+
to the :file:`pyNN_dev/pyNN` directory.
7162

7263
Coding style
7364
============
@@ -80,7 +71,7 @@ We try to stay fairly close to PEP8_. Please note in particular:
8071
- some function/method names in PyNN use ``mixedCase``, but these will
8172
gradually be deprecated and replaced with ``lower_case_with_underscores``.
8273
Any new functions or methods should use the latter.
83-
- we currently target versions 2.7 and 3.6+
74+
- we currently target versions 3.8+
8475

8576

8677
Testing
@@ -190,16 +181,16 @@ last time:
190181
you should do this on at least two Linux systems and one Mac OS X system.
191182
* does the documentation build without errors? You should then at least skim
192183
the generated HTML pages to check for obvious problems.
193-
* have you updated the version numbers in :file:`setup.py`, :file:`pyNN/__init__.py`,
184+
* have you updated the version numbers in :file:`pyproject.toml`, :file:`pyNN/__init__.py`,
194185
:file:`doc/conf.py` and :file:`doc/installation.txt`?
195186
* have you updated the changelog?
196187

197-
Once you've confirmed all the above, create a source package using::
188+
Once you've confirmed all the above, create source and wheel packages using::
198189

199-
$ python setup.py sdist
190+
$ python -m build
200191

201-
and check that it installs properly (you will find it in the :file:`dist`
202-
subdirectory.
192+
and check that they install properly (you will find them in the :file:`dist`
193+
subdirectory).
203194

204195
Now you should commit any changes, then tag with the release number as follows::
205196

@@ -213,24 +204,16 @@ to http://neuralensemble.org/docs/PyNN/ by running::
213204
in the :file:`doc` directory, and then unpacking the resulting archive on the
214205
NeuralEnsemble server.
215206

216-
If this is a development release (i.e. an *alpha* or *beta*), the final step is
217-
to upload the source package to the INCF Software Center.
218-
Do **not** upload development releases to PyPI.
219-
220-
To upload a package to the INCF Software Center, log-in, and then go to the
221-
Contents_ tab. Click on "Add new..." then "File", then fill in the form and
222-
upload the source package.
223-
224207
If this is a final release, there are a few more steps:
225208

226209
* if it is a major release (i.e. an ``x.y.0`` release), create a new bug-fix
227210
branch::
228211

229212
$ git branch x.y
230213

231-
* upload the source package to PyPI::
214+
* upload the packages to PyPI (Do **not** upload development releases to PyPI)::
232215

233-
$ python setup.py sdist upload
216+
$ twine upload dist/PyNN-x.y.z*
234217

235218
* make an announcement on the `mailing list`_
236219

doc/installation.txt

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ install and run PyNN on Windows, but this has not been tested.
77

88
Installing PyNN requires:
99

10-
* Python (version 3.7+)
10+
* Python (version 3.8+)
1111
* a recent version of the NumPy_ package
1212
* the lazyarray_ package
1313
* the Neo_ package (>= 0.11.0)
@@ -32,9 +32,8 @@ The easiest way to get PyNN is to use pip_::
3232
If you would prefer to install manually, :doc:`download the latest
3333
source distribution <download>`, then run the setup script, e.g.::
3434

35-
$ tar xzf PyNN-0.10.1.tar.gz
36-
$ cd PyNN-0.10.1
37-
$ python setup.py install
35+
$ tar xzf PyNN-0.11.0.tar.gz
36+
$ pip install ./PyNN-0.11.0
3837

3938
This will install it to your Python :file:`site-packages` directory, and may
4039
require root privileges. We strongly recommend, however, that you use a
@@ -55,30 +54,25 @@ Test it using something like the following::
5554
If you get a warning "Unable to install NEST extensions. Certain models may not be available" then ensure the
5655
program :command:`nest-config` is on your system PATH.
5756
If you still get this message even after adding the directory containing :command:`nest-config` to the PATH,
58-
try ``pip uninstall PyNN``, then re-install with ``pip install --no-binary :all: PyNN``
57+
then you will still be able to use pyNN.nest, just a small number of models will not be available.
5958

60-
With NEURON as the simulator, make sure you install NEURON *before* you install PyNN.
61-
The PyNN installation will then compile PyNN-specific membrane mechanisms, which are loaded when importing the :mod:`neuron` module::
59+
For NEURON, PyNN will compile PyNN-specific membrane mechanisms the first time you import the :mod:`neuron` module::
6260

6361
>>> import pyNN.neuron as sim
64-
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
65-
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
66-
See http://www.neuron.yale.edu/neuron/credits
67-
68-
loading membrane mechanisms from /home/docker/dev/PyNN/pyNN/neuron/nmodl/x86_64/.libs/libnrnmech.so
69-
Additional mechanisms from files
70-
adexp.mod alphaisyn.mod alphasyn.mod expisyn.mod gap.mod gsfa_grr.mod hh_traub.mod
71-
izhikevich.mod netstim2.mod refrac.mod reset.mod stdwa_guetig.mod stdwa_softlimits.mod
72-
stdwa_songabbott.mod stdwa_symm.mod stdwa_vogels2011.mod tmgsyn.mod tmisyn.mod
73-
tsodyksmarkram.mod vecstim.mod
7462

75-
If you installed PyNN before installing NEURON, or if you update your PyNN installation,
76-
you will need to manually run :command:`nrnivmodl` in the :file:`pyNN/neuron/nmodl` directory.
7763

7864
Installing NEURON
7965
=================
8066

81-
Download the sources for NEURON 7.4 or later, in ``.tar.gz`` format, from `<http://www.neuron.yale.edu/neuron/download/getstd>`_.
67+
For recent versions of NEURON,
68+
69+
::
70+
71+
$ pip install neuron
72+
73+
may be all you need. If you have more complex needs, try the following.
74+
75+
Download the sources for NEURON 8.0 or later, in ``.tar.gz`` format, from `<http://www.neuron.yale.edu/neuron/download/getstd>`_.
8276
Also download Interviews from the same location.
8377

8478
Compile Interviews and NEURON according to the instructions given at `<http://www.neuron.yale.edu/neuron/static/download/compilestd_unix.html>`_,
@@ -92,9 +86,9 @@ Make sure that you add the Interviews and NEURON :file:`bin` directories to your
9286
Test that the Python support has been enabled by running::
9387

9488
$ nrniv -python
95-
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
96-
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
97-
See http://www.neuron.yale.edu/neuron/credits
89+
NEURON -- VERSION 8.2.2 release/8.2 (93d41fafd) 2022-12-15
90+
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2022
91+
See http://neuron.yale.edu/neuron/credits
9892

9993
>>> import hoc
10094
>>> import nrn
@@ -108,35 +102,31 @@ Now test everything worked::
108102

109103
$ python
110104
>>> import neuron
111-
NEURON -- Release 7.4 (1370:16a7055d4a86) 2015-11-09
112-
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2015
113-
See http://www.neuron.yale.edu/neuron/credits
114105

115106
If you run into problems, check out the `NEURON Forum`_.
116107

117108

118109
Installing NEST and PyNEST
119110
==========================
120111

121-
NEST 2.18.0 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
112+
NEST 3.4 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
122113
Earlier versions of NEST may not work with this version of PyNN.
123-
The full installation instructions are available in the file INSTALL, which you can find in the NEST source package,
124-
or at `<http://www.nest-simulator.org/installation/>`_.
114+
The full installation instructions are available at `<https://nest-simulator.readthedocs.io/en/v3.4/installation/index.html/>`_.
125115

126116
Now try it out::
127117

128118
$ cd ~
129119
$ python
130120
>>> import nest
131-
-- N E S T --
132-
Copyright (C) 2004 The NEST Initiative
133121

134-
Version: v2.20.0
122+
-- N E S T --
123+
Copyright (C) 2004 The NEST Initiative
135124

125+
Version: 3.4
136126
...
137-
>>> nest.Models()
138-
(u'ac_generator', u'aeif_cond_alpha', u'aeif_cond_alpha_RK5', u'aeif_cond_alpha_multisynapse',
139-
...
127+
128+
>>> nest.node_models
129+
('weight_recorder', 'gauss_rate_ipn', 'lin_rate_ipn', 'sigmoid_rate_ipn', 'sigmoid_rate_gg_1998_ipn', 'tanh_rate_ipn', ...)
140130

141131
Check that ``'aeif_cond_alpha'`` is in the list of models. If it is not, you may need to install a newer version of the `GNU Scientific Library`_ and then recompile NEST.
142132

pyNN/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
:license: CeCILL, see LICENSE for details.
7070
"""
7171

72-
__version__ = '0.10.2.dev'
72+
__version__ = '0.11.0.dev'
7373
__all__ = ["common", "random", "nest", "neuron", "brian2",
7474
"recording", "errors", "space", "descriptions",
75-
"standardmodels", "parameters", "core", "serialization"]
75+
"standardmodels", "parameters", "core", "serialization",
76+
"utility"]

pyNN/core.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
:license: CeCILL, see LICENSE for details.
66
"""
77

8+
import os
9+
import subprocess
810
import warnings
911
import numpy as np
1012

@@ -56,6 +58,27 @@ def ezip(*args):
5658
yield items[0], items[1:]
5759

5860

61+
def find(command):
62+
"""Try to find an executable file."""
63+
path = os.environ.get("PATH", "").split(os.pathsep)
64+
cmd = ''
65+
for dir_name in path:
66+
abs_name = os.path.abspath(os.path.normpath(os.path.join(dir_name, command)))
67+
if os.path.isfile(abs_name):
68+
cmd = abs_name
69+
break
70+
return cmd
71+
72+
73+
def run_command(path, working_directory):
74+
p = subprocess.Popen(path, shell=True, stdin=subprocess.PIPE,
75+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
76+
universal_newlines=True,
77+
cwd=working_directory)
78+
stdout, stderr = p.communicate()
79+
return p.returncode, stdout.split("\n")
80+
81+
5982
class IndexBasedExpression(object):
6083
"""
6184
Abstract base class for general expressions that use the cell indices and projection class to

pyNN/nest/simulator.py

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
:license: CeCILL, see LICENSE for details.
2020
"""
2121

22-
import nest
22+
import os.path
2323
import logging
2424
import tempfile
2525
import warnings
2626
import numpy as np
27+
28+
import nest
29+
2730
from .. import common
28-
from ..core import reraise
31+
from ..core import reraise, find, run_command
2932

3033
logger = logging.getLogger("PyNN")
3134
name = "NEST" # for use in annotating output data
@@ -39,6 +42,57 @@
3942
NEST_ARRAY_VARIABLES_TIME_DIMENSION = ("spike_times", "amplitude_times", "rate_times")
4043

4144

45+
# --- Building extensions ------------------------------------------------------
46+
47+
def build_extensions(build_dir=None):
48+
nest_config = find("nest-config")
49+
if not nest_config:
50+
warnings.warn("Cannot find nest-config, please check your PATH. Unable to build extensions.")
51+
return
52+
53+
logger.debug("nest-config found at", nest_config)
54+
55+
build_dirs = []
56+
if build_dir is not None:
57+
build_dirs.append(build_dir)
58+
# if a specific build directory is not provided,
59+
# first try to build within the pyNN source dir
60+
build_dirs.append(os.path.join(os.path.dirname(__file__), "_build"))
61+
# if that directory is not writable, build in the current working directory
62+
build_dirs.append(os.path.join(os.getcwd(), "_build", "nest_extensions"))
63+
64+
for nest_build_dir in build_dirs:
65+
try:
66+
os.makedirs(nest_build_dir, exist_ok=True)
67+
except OSError:
68+
continue
69+
if os.access(nest_build_dir, os.W_OK):
70+
break
71+
72+
if not os.access(nest_build_dir, os.W_OK):
73+
warnings.warn("Cannot create build directory for nest extensions")
74+
return
75+
76+
source_dir = os.path.join(os.path.dirname(__file__), "extensions")
77+
result, stdout = run_command(f"cmake -Dwith-nest={nest_config} {source_dir}",
78+
nest_build_dir)
79+
if result != 0:
80+
err_msg = "\n ".join(stdout)
81+
warnings.warn(f"Problem running cmake. Output was:\n {err_msg}")
82+
else:
83+
result, stdout = run_command("make", nest_build_dir)
84+
if result != 0:
85+
err_msg = "\n ".join(stdout)
86+
warnings.warn(f"Unable to compile NEST extensions. Output was:\n {err_msg}")
87+
else:
88+
result, stdout = run_command("make install", nest_build_dir)
89+
if result != 0:
90+
err_msg = "\n ".join(stdout)
91+
warnings.warn(f"Unable to install NEST extensions. Output was:\n {err_msg}")
92+
else:
93+
logger.info("Successfully compiled NEST extensions.")
94+
95+
4296
# --- For implementation of get_time_step() and similar functions --------------
4397

4498

@@ -77,7 +131,12 @@ def __init__(self):
77131
nest.Install('pynn_extensions')
78132
self.extensions_loaded = True
79133
except nest.NESTError:
80-
self.extensions_loaded = False
134+
build_extensions()
135+
try:
136+
nest.Install('pynn_extensions')
137+
self.extensions_loaded = True
138+
except nest.NESTError:
139+
self.extensions_loaded = False
81140
self.initialized = False
82141
self.optimize = False
83142
self.spike_precision = "off_grid"

0 commit comments

Comments
 (0)