diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce6f4d91..75a38363 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,27 +36,23 @@ jobs: echo "github.ref is: ${{ github.ref }}" echo "github.base_ref is: ${{ github.base_ref }}" - - name: Install deps from development + - name: Upgrade pip, install inspyred + run: | + python -m pip install --upgrade pip + pip install git+https://github.com/aarongarrett/inspyred.git@master#egg=inspyred + pip install .[all] + + - name: Install package and development deps if: ${{ github.ref == 'refs/heads/development' || github.base_ref == 'development' }} run: | echo "Using deps from development for our repos" - cp -v requirements-development.txt requirements.txt + pip install .[dev] - - name: Install deps from experimental + - name: Install package and experimental deps if: ${{ github.ref == 'refs/heads/experimental' || github.base_ref == 'experimental' }} run: | echo "Using deps from experimental - assuming development in others" - cp -v requirements-experimental.txt requirements.txt - - - name: Install package - run: | - python -m pip install --upgrade pip - - # Ensure very latest inspyred (not on pypi) is installed - pip install git+https://github.com/aarongarrett/inspyred.git@master#egg=inspyred - - pip install -r requirements.txt - pip install . + pip install .[experimental] - name: List packages so far run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..25398389 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files +- repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7dd9ee01..2d3d2d5d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,4 +12,7 @@ sphinx: python: install: - - requirements: docs/requirements.txt + - method: pip + path: . + extra_requirements: + - doc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 374a6cac..a60b4c27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,6 +17,14 @@ pyNeuroML. Pull requests with enhancements and bug fixes are welcome. ## Pull Request Process -1. Please ensure that the automated build for your pull request passes. -2. Please pay attention to the results from flake8 and make any modifications +1. Please contribute pull requests against the `development` branch. +2. Please ensure that the automated build for your pull request passes. +3. Please pay attention to the results from flake8 and make any modifications to ensure a consistent code style. + +## Pre-commit + +A number of [pre-commit](https://pre-commit.com/) hooks are used to improve code-quality. +Please run the following code to set up the pre-commit hooks: + + $ pre-commit install diff --git a/MANIFEST.in b/MANIFEST.in index 6feb84bb..c5ca8dfd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,8 @@ include README.md +include CONTRIBUTING.md include LICENSE* -include requirements.txt +include *.sh +recursive-include tests * +recursive-include man * +recursive-include examples * +recursive-include docs * diff --git a/README.md b/README.md index a137d9ef..b0482c68 100644 --- a/README.md +++ b/README.md @@ -59,16 +59,14 @@ Clone the repository: It should be possible to install pyNeuroML using just: - sudo pip install . + pip install . -You **may** have to install lxml and the development version of [libNeuroML](https://github.com/NeuralEnsemble/libNeuroML) manually: +To develop pyNeuroML, you can use the `dev` extra and the `development` branch: - apt-get install python-lxml - cd .. - git clone https://github.com/NeuralEnsemble/libNeuroML.git - cd libNeuroML + git clone https://github.com/NeuroML/pyNeuroML.git + cd pyNeuroML git checkout development - sudo python setup.py install + pip install .[dev] Current/planned features diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 32e66e7c..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -sphinxcontrib-bibtex -lxml -airspeed -opencv-python -libneuroml -pyelectro -matplotlib -matplotlib_scalebar -plotly -scipy -pylems -graphviz -argparse -neuromllite -neurotune>=0.2.6 # now manages the version of inspyred -neuron -pydata-sphinx-theme -vispy diff --git a/pyneuroml/__init__.py b/pyneuroml/__init__.py index 76f93034..f6e1fa40 100644 --- a/pyneuroml/__init__.py +++ b/pyneuroml/__init__.py @@ -1,6 +1,12 @@ import logging -__version__ = "1.0.8" +try: + import importlib.metadata + __version__ = importlib.metadata.version("pyNeuroML") +except ImportError: + import importlib_metadata + __version__ = importlib_metadata.version("pyNeuroML") + JNEUROML_VERSION = "0.12.2" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fed528d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/requirements-development.txt b/requirements-development.txt deleted file mode 100644 index 88741fdb..00000000 --- a/requirements-development.txt +++ /dev/null @@ -1,24 +0,0 @@ -argparse -airspeed>=0.5.5 -matplotlib -graphviz -vispy -pyqt5 -NEURON -ppft - -git+https://github.com/ModECI/modelspec.git@development#egg=modelspec -git+https://github.com/NeuralEnsemble/libNeuroML.git@development#egg=libNeuroML -git+https://github.com/LEMS/pylems.git@development#egg=pylems - -pyelectro -neurotune>=0.2.6 # now manages the version of inspyred - -pytest -pytest-cov - -plotly -kaleido -matplotlib-scalebar - -pyyaml diff --git a/requirements-experimental.txt b/requirements-experimental.txt deleted file mode 100644 index 1225ac05..00000000 --- a/requirements-experimental.txt +++ /dev/null @@ -1,25 +0,0 @@ -argparse -airspeed>=0.5.5 -matplotlib -graphviz -vispy -pyqt5 -NEURON -ppft - -git+https://github.com/ModECI/modelspec.git@development#egg=modelspec -git+https://github.com/NeuralEnsemble/libNeuroML.git@development#egg=libNeuroML -git+https://github.com/LEMS/pylems.git@development#egg=pylems - -pyelectro -neurotune>=0.2.6 # now manages the version of inspyred - - -pytest -pytest-cov - -plotly -kaleido -matplotlib-scalebar - -pyyaml diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 076cd6dc..00000000 --- a/requirements.txt +++ /dev/null @@ -1,24 +0,0 @@ -argparse -airspeed>=0.5.5 -matplotlib -graphviz -vispy -pyqt5 -NEURON -ppft - -git+https://github.com/NeuralEnsemble/libNeuroML.git@master#egg=libNeuroML -git+https://github.com/LEMS/pylems.git@master#egg=pylems - -pyelectro -neurotune>=0.2.6 # now manages the version of inspyred - - -pytest -pytest-cov - -plotly -kaleido -matplotlib-scalebar - -pyyaml diff --git a/setup.cfg b/setup.cfg index 2827df5c..61d4d281 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,133 @@ +[metadata] +name = pyNeuroML +version = 1.0.8 +author = Padraig Gleeson +author_email = p.gleeson@gmail.com +url = https://github.com/NeuroML/pyNeuroML +license = LGPL-3.0-only +description = Python utilities for NeuroML +long_description = file: README.md +long_description_content_type = text/markdown +classifiers= + Intended Audience :: Science/Research + License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3) + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Topic :: Scientific/Engineering + +[options] +install_requires = + pylems>=0.5.7 + airspeed>=0.5.5 + neuromllite>=0.5.4 + libNeuroML>=0.5.1 + matplotlib + matplotlib-scalebar + graphviz + typing; python_version<"3.5" + lxml + pandas + argparse + +packages = find: + +[options.packages.find] +where = . +include = pyneuroml* + +[options.entry_points] +console_scripts = + pynml = pyneuroml.pynml:main + pynml-archive = pyneuroml.archive:main + pynml-channelanalysis = pyneuroml.analysis.NML2ChannelAnalysis:main + pynml-modchananalysis = pyneuroml.neuron.analysis.HHanalyse:main + pynml-povray = pyneuroml.povray.NeuroML2ToPOVRay:main + pynml-tune = pyneuroml.tune.NeuroMLTuner:main + pynml-summary = pyneuroml.pynml:summary + pynml-plotspikes = pyneuroml.plot.PlotSpikes:main + pynml-plotmorph = pyneuroml.plot.PlotMorphology:main + pynml-channelml2nml = pyneuroml.channelml:main + pynml-sonata = neuromllite.SonataReader:main + +[options.package_data] +* = + lib/*.jar + *.xml + *.html + *.md + *.xsl + *.hoc + +[options.extras_require] +neuron = + NEURON + pyyaml + +brian = + Brian2 + +netpyne = + netpyne + +povray = + opencv-python + +hdf5 = + tables + +analysis = + pyelectro + +tune = + neurotune>=0.2.6 + ppft + +vispy = + vispy + pyqt5 + +plotly = + plotly + +all = + pyNeuroML[neuron] + pyNeuroML[brian] + pyNeuroML[netpyne] + pyNeuroML[netpyne] + pyNeuroML[povray] + pyNeuroML[hdf5] + pyNeuroML[analysis] + pyNeuroML[tune] + pyNeuroML[vispy] + pyNeuroML[plotly] + +dev = + pyNeuroML[all] + airspeed>=0.5.5 + modelspec @ git+https://github.com/ModECI/modelspec.git@development#egg=modelspec + libNeuroML @ git+https://github.com/NeuralEnsemble/libNeuroML.git@development#egg=libNeuroML + pylems @ git+https://github.com/LEMS/pylems.git@development#egg=pylems + pytest + pytest-cov + kaleido + pre-commit + +experimental = + pyNeuroML[dev] + + modelspec @ git+https://github.com/ModECI/modelspec.git@development#egg=modelspec + libNeuroML @ git+https://github.com/NeuralEnsemble/libNeuroML.git@development#egg=libNeuroML + pylems @ git+https://github.com/LEMS/pylems.git@development#egg=pylems + +doc = + pyNeuroML[all] + sphinxcontrib-bibtex + pydata-sphinx-theme + [flake8] ignore = E501, E502, F403, F405 diff --git a/setup.py b/setup.py deleted file mode 100644 index f509a968..00000000 --- a/setup.py +++ /dev/null @@ -1,119 +0,0 @@ -from setuptools import setup - -import pyneuroml - -version = pyneuroml.__version__ -jnml_version = pyneuroml.JNEUROML_VERSION - -# generate extra deps -extras = { - "neuron": ["NEURON", "pyyaml"], - "brian": ["Brian2"], - "netpyne": ["netpyne"], - "povray": ["opencv-python"], - "hdf5": ["tables"], - "analysis": ["pyelectro"], - "tune": ["neurotune", - "ppft"], - "vispy": ["vispy", "pyqt5"], -} -extras["all"] = sum(extras.values(), []), - -setup( - name="pyNeuroML", - version=version, - author="Padraig Gleeson", - author_email="p.gleeson@gmail.com", - packages=[ - "pyneuroml", - "pyneuroml.analysis", - "pyneuroml.archive", - "pyneuroml.channelml", - "pyneuroml.lems", - "pyneuroml.tune", - "pyneuroml.neuron", - "pyneuroml.povray", - "pyneuroml.plot", - "pyneuroml.swc", - "pyneuroml.neuron.analysis", - "pyneuroml.utils", - ], - entry_points={ - "console_scripts": [ - "pynml = pyneuroml.pynml:main", - "pynml-archive = pyneuroml.archive:main", - "pynml-channelanalysis = pyneuroml.analysis.NML2ChannelAnalysis:main", - "pynml-modchananalysis = pyneuroml.neuron.analysis.HHanalyse:main", - "pynml-povray = pyneuroml.povray.NeuroML2ToPOVRay:main", - "pynml-tune = pyneuroml.tune.NeuroMLTuner:main", - "pynml-summary = pyneuroml.pynml:summary", - "pynml-plotspikes = pyneuroml.plot.PlotSpikes:main", - "pynml-plotmorph = pyneuroml.plot.PlotMorphology:main", - "pynml-channelml2nml = pyneuroml.channelml:main", - "pynml-sonata = neuromllite.SonataReader:main", - ] - }, - package_data={ - "pyneuroml": [ - "lib/jNeuroML-{}-jar-with-dependencies.jar".format(jnml_version), - "analysis/LEMS_Test_TEMPLATE.xml", - "analysis/ChannelInfo_TEMPLATE.html", - "analysis/ChannelInfo_TEMPLATE.md", - "lems/LEMS_TEMPLATE.xml", - "neuron/utils.hoc", - "neuron/mview_neuroml1.hoc", - "neuron/mview_neuroml2.hoc", - "neuron/TEMPLATE.channel.nml", - "channelml/ChannelML2NeuroML2.xsl", - "channelml/ChannelML2NeuroML2beta.xsl", - ] - }, - data_files=[ - ( - "share/man/man1", - [ - "man/man1/pynml.1", - "man/man1/pynml-modchananalysis.1", - "man/man1/pynml-povray.1", - "man/man1/pynml-tune.1", - "man/man1/pynml-channelanalysis.1", - "man/man1/pynml-channelml2nml.1", - "man/man1/pynml-plotspikes.1", - "man/man1/pynml-plotmorph.1", - "man/man1/pynml-summary.1", - "man/man1/pynml-sonata.1", - ], - ) - ], - url="https://github.com/NeuroML/pyNeuroML", - license="LICENSE.lesser", - description="Python utilities for NeuroML", - long_description=open("README.md").read(), - long_description_content_type="text/markdown", - install_requires=[ - "pylems>=0.5.7", - "airspeed>=0.5.5", - "neuromllite>=0.5.4", - "libNeuroML>=0.5.1", - "matplotlib", - "matplotlib-scalebar", - "graphviz", - 'typing; python_version<"3.5"', - "lxml", - "pandas", - "plotly" - ], - extras_require=extras, - classifiers=[ - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Scientific/Engineering", - ], -) diff --git a/tests/test_pynml.py b/tests/test_pynml.py index 5729b7e0..416f11ad 100644 --- a/tests/test_pynml.py +++ b/tests/test_pynml.py @@ -171,7 +171,7 @@ def test_validate_neuroml2(self): retval = None retstring = None - retval, retstring = validate_neuroml2("setup.py", return_string=True) + retval, retstring = validate_neuroml2("setup.cfg", return_string=True) self.assertFalse(retval) self.assertIn("1 failed", retstring)