forked from robbert-harms/MDT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
126 lines (102 loc) · 4.35 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import glob
from textwrap import dedent
import os
import sys
from setuptools import setup, find_packages, Command
def load_requirements(fname):
is_comment = re.compile('^\s*(#|--).*').match
with open(fname) as fo:
return [line.strip() for line in fo if not is_comment(line) and line.strip()]
with open('README.rst', 'rt') as f:
readme = f.read()
with open('mdt/__version__.py') as f:
version_file_contents = "\n".join(f.readlines())
ver_dic = {}
exec(compile(version_file_contents, "mdt/__version__.py", 'exec'), ver_dic)
requirements = load_requirements('requirements.txt')
requirements_tests = load_requirements('requirements_tests.txt')
long_description = readme
if sys.argv and len(sys.argv) > 3 and sys.argv[2] == 'debianize':
long_description = dedent("""
The Microstructure Diffusion Toolbox is a parallized neuro-imaging model recovery toolbox.
Being GPU accelerated, it allows for high-performance computing in MRI imaging analysis.
""").lstrip()
def load_entry_points():
entry_points = {'console_scripts': []}
for file in glob.glob('mdt/cli_scripts/*.py'):
module_name = os.path.splitext(os.path.basename(file))[0]
command_name = module_name.replace('_', '-')
def get_command_class_name():
with open(file) as f:
match = re.search(r'class (\w*)\(', f.read())
if match:
return match.group(1)
return None
command_class_name = get_command_class_name()
if command_class_name is not None:
script = '{command_name} = mdt.cli_scripts.{module_name}:{class_name}.console_script'.format(
command_name=command_name, module_name=module_name, class_name=command_class_name)
entry_points['console_scripts'].append(script)
return entry_points
info_dict = dict(
name='mdt',
version=ver_dic["VERSION"],
description='Microstructure Diffusion Toolbox',
long_description=long_description,
author='Robbert Harms',
author_email='robbert.harms@maastrichtuniversity.nl',
maintainer='Robbert Harms',
maintainer_email='robbert.harms@maastrichtuniversity.nl',
url='https://github.com/cbclab/MDT',
packages=find_packages(),
include_package_data=True,
install_requires=requirements,
license="LGPL v3",
zip_safe=False,
keywords='mdt, diffusion MRI, model recovery, imaging analysis',
classifiers=[
'Environment :: Console',
'Environment :: X11 Applications :: Qt',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Development Status :: 5 - Production/Stable',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering'
],
test_suite='tests',
tests_require=requirements_tests,
entry_points=load_entry_points()
)
class PrepareDebianDist(Command):
description = "Prepares the debian dist prior to packaging."
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def run(self):
with open('./debian/rules', 'a') as f:
f.write('\noverride_dh_auto_test:\n\techo "Skip dh_auto_test"')
self._set_copyright_file()
def _set_copyright_file(self):
with open('./debian/copyright', 'r') as file:
copyright_info = file.read()
copyright_info = copyright_info.replace('{{source}}', info_dict['url'])
copyright_info = copyright_info.replace('{{years}}', '2015-2018')
copyright_info = copyright_info.replace('{{author}}', info_dict['author'])
copyright_info = copyright_info.replace('{{email}}', info_dict['author_email'])
with open('./debian/copyright', 'w') as file:
file.write(copyright_info)
info_dict.update(cmdclass={'prepare_debian_dist': PrepareDebianDist})
setup(**info_dict)