Skip to content

Commit

Permalink
feat: Add black, isort, pre-commit hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtdang committed Mar 19, 2024
1 parent 21dcea5 commit 8f23875
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 77 deletions.
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/ambv/black
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args:
- "--profile=black"
- "--filter-files"
- "--project=autora"
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
default_language_version:
python: python3
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[build-system]
requires = ["setuptools>=40.8.0", "NEURON >=7.7; platform_system != 'Windows'"]
build-backend = "setuptools.build_meta:__legacy__"

[tool.codespell]
skip = '.git,*.pdf,*.svg'
check-hidden = true
# in jupyter notebooks - images and also some embedded outputs
ignore-regex = '^\s*"image/\S+": ".*|.*%22%3A%20.*'
ignore-words-list = 'tha,nam,sherif,dout'

[tool.isort]
profile = "black"
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[flake8]
exclude = __init__.py
ignore = E722, W504
max-line-length = 80
extend-select = B950
extend-ignore = E203,E501,E701

[check-manifest]
ignore =
Expand Down
178 changes: 102 additions & 76 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
#! /usr/bin/env python
import platform
import os.path as op
import os
import subprocess
import os.path as op
import platform
import shutil

from setuptools import setup, find_packages

from distutils.command.build_py import build_py
import subprocess
from distutils.cmd import Command
from distutils.command.build_py import build_py

from setuptools import find_packages, setup

descr = """Code for biophysical simulation of a cortical column using Neuron"""

DISTNAME = 'hnn-core'
DISTNAME = "hnn-core"
DESCRIPTION = descr
MAINTAINER = 'Mainak Jas'
MAINTAINER_EMAIL = '[email protected]'
URL = ''
LICENSE = 'BSD (3-clause)'
DOWNLOAD_URL = 'http://github.com/jonescompneurolab/hnn-core'
MAINTAINER = "Mainak Jas"
MAINTAINER_EMAIL = "[email protected]"
URL = ""
LICENSE = "BSD (3-clause)"
DOWNLOAD_URL = "http://github.com/jonescompneurolab/hnn-core"

# get the version
version = None
with open(os.path.join('hnn_core', '__init__.py'), 'r') as fid:
with open(os.path.join("hnn_core", "__init__.py"), "r") as fid:
for line in (line.strip() for line in fid):
if line.startswith('__version__'):
version = line.split('=')[1].strip().strip('\'')
if line.startswith("__version__"):
version = line.split("=")[1].strip().strip("'")
break
if version is None:
raise RuntimeError('Could not determine version')
raise RuntimeError("Could not determine version")


# test install with:
Expand All @@ -51,15 +50,19 @@ def finalize_options(self):
def run(self):
print("=> Building mod files ...")

if platform.system() == 'Windows':
if platform.system() == "Windows":
shell = True
else:
shell = False

mod_path = op.join(op.dirname(__file__), 'hnn_core', 'mod')
process = subprocess.Popen(['nrnivmodl'], cwd=mod_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=shell)
mod_path = op.join(op.dirname(__file__), "hnn_core", "mod")
process = subprocess.Popen(
["nrnivmodl"],
cwd=mod_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=shell,
)
outs, errs = process.communicate()
print(outs)

Expand All @@ -68,65 +71,88 @@ class build_py_mod(build_py):
def run(self):
self.run_command("build_mod")

build_dir = op.join(self.build_lib, 'hnn_core', 'mod')
mod_path = op.join(op.dirname(__file__), 'hnn_core', 'mod')
build_dir = op.join(self.build_lib, "hnn_core", "mod")
mod_path = op.join(op.dirname(__file__), "hnn_core", "mod")
shutil.copytree(mod_path, build_dir)

build_py.run(self)


if __name__ == "__main__":
extras = {
'opt': ['scikit-learn'],
'parallel': ['joblib', 'psutil'],
'test': ['flake8', 'pytest', 'pytest-cov', ],
'docs': ['mne', 'nibabel', 'pooch', 'tdqm',
'sphinx', 'nbsphinx', 'sphinx-gallery',
'sphinx_bootstrap_theme', 'sphinx-copybutton',
'pillow', 'numpydoc',
],
'gui': ['ipywidgets>=8.0.0', 'ipykernel', 'ipympl', 'voila', ],
"opt": ["scikit-learn"],
"parallel": ["joblib", "psutil"],
"test": [
"flake8",
"flake8-bugbear",
"black",
"pre-commit",
"isort",
"pytest",
"pytest-cov",
],
"docs": [
"mne",
"nibabel",
"pooch",
"tdqm",
"sphinx",
"nbsphinx",
"sphinx-gallery",
"sphinx_bootstrap_theme",
"sphinx-copybutton",
"pillow",
"numpydoc",
],
"gui": [
"ipywidgets>=8.0.0",
"ipykernel",
"ipympl",
"voila",
],
}
extras['dev'] = (extras['opt'] + extras['parallel'] + extras['test'] +
extras['docs'] + extras['gui']
)


setup(name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=version,
download_url=DOWNLOAD_URL,
long_description=open('README.rst').read(),
classifiers=[
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved',
'Programming Language :: Python',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
],
platforms='any',
install_requires=[
'numpy >=1.14',
'NEURON >=7.7; platform_system != "Windows"',
'matplotlib>=3.5.3',
'scipy',
'h5io'
],
extras_require=extras,
python_requires='>=3.8',
packages=find_packages(),
package_data={'hnn_core': [
'param/*.json',
'gui/*.ipynb']},
cmdclass={'build_py': build_py_mod, 'build_mod': BuildMod},
entry_points={'console_scripts': ['hnn-gui=hnn_core.gui.gui:launch']}
)
extras["dev"] = (
extras["opt"]
+ extras["parallel"]
+ extras["test"]
+ extras["docs"]
+ extras["gui"]
)

setup(
name=DISTNAME,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
license=LICENSE,
url=URL,
version=version,
download_url=DOWNLOAD_URL,
long_description=open("README.rst").read(),
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
],
platforms="any",
install_requires=[
"numpy >=1.14",
'NEURON >=7.7; platform_system != "Windows"',
"matplotlib>=3.5.3",
"scipy",
"h5io",
],
extras_require=extras,
python_requires=">=3.8",
packages=find_packages(),
package_data={"hnn_core": ["param/*.json", "gui/*.ipynb"]},
cmdclass={"build_py": build_py_mod, "build_mod": BuildMod},
entry_points={"console_scripts": ["hnn-gui=hnn_core.gui.gui:launch"]},
)

0 comments on commit 8f23875

Please sign in to comment.