-
Notifications
You must be signed in to change notification settings - Fork 52
/
setup.py
130 lines (111 loc) · 4.05 KB
/
setup.py
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
127
128
129
130
#! /usr/bin/env python
import platform
import os.path as op
import os
import subprocess
import shutil
from setuptools import setup, find_packages, Command
from setuptools.command.build_py import build_py
descr = """Code for biophysical simulation of a cortical column using Neuron"""
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'
# get the version
version = None
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('\'')
break
if version is None:
raise RuntimeError('Could not determine version')
# test install with:
# $ rm -rf hnn_core/mod/x86_64/
# $ python setup.py clean --all install
#
# to make sure there are no residual mod files
#
# also see following link to understand why build_py must be overridden:
# https://stackoverflow.com/questions/51243633/python-setuptools-setup-py-install-does-not-automatically-call-build
class BuildMod(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("=> Building mod files ...")
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)
outs, errs = process.communicate()
print(outs)
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')
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', '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']}
)