forked from mdp-toolkit/mdp-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
113 lines (97 loc) · 4.03 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
from setuptools import setup
from setuptools.command.test import test as _test
import os
import sys
email = '[email protected]'
classifiers = ["Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Mathematics"]
def get_module_code():
# keep old python compatibility, so no context managers
mdp_init = open(os.path.join(os.getcwd(), 'mdp', '__init__.py'))
module_code = mdp_init.read()
mdp_init.close()
return module_code
def throw_bug():
raise ValueError('Can not get MDP version!\n'
'Please report a bug to ' + email)
import ast
def get_extract_variable(tree, variable):
for node in ast.walk(tree):
if type(node) is ast.Assign:
try:
if node.targets[0].id == variable:
return node.value.s
except:
pass
throw_bug()
def get_mdp_ast_tree():
return ast.parse(get_module_code())
def get_version():
tree = get_mdp_ast_tree()
return get_extract_variable(tree, '__version__')
def get_short_description():
tree = get_mdp_ast_tree()
return get_extract_variable(tree, '__short_description__')
def get_long_description():
tree = get_mdp_ast_tree()
return ast.get_docstring(tree)
class MDPTest(_test):
def run_tests(self):
from mdp.test import test as mtest
from bimdp.test import test as btest
# Fix random seed here, as we want reproducible failures in
# automatic builds using "python setup.py test"
# If the tests are run manually with pytest or
# using the mdp.test and bimdp.test functions, the seed
# is not set
errno = mtest(seed=725021957)
errno += btest(seed=725021957)
sys.exit(errno)
def setup_package():
# check that we have a version
version = get_version()
short_description = get_short_description()
long_description = get_long_description()
# create download url:
dl = ('https://github.com/mdp-toolkit/mdp-toolkit/archive/MDP-' + get_version()+'.zip')
setup(name = 'MDP', version=version,
author = 'MDP Developers',
author_email = email,
maintainer = 'MDP Developers',
maintainer_email = email,
license = "https://raw.githubusercontent.com/mdp-toolkit/mdp-toolkit/master/COPYRIGHT",
platforms = ["Any"],
url = 'https://mdp-toolkit.github.io',
download_url = dl,
description = short_description,
long_description = long_description,
classifiers = classifiers,
packages = ['mdp', 'mdp.nodes', 'mdp.utils', 'mdp.hinet',
'mdp.test', 'mdp.graph', 'mdp.caching',
'mdp.parallel', 'bimdp', 'bimdp.hinet', 'bimdp.inspection',
'bimdp.nodes', 'bimdp.parallel', 'bimdp.test'],
package_data = {'mdp.hinet': ['hinet.css'],
'mdp.utils': ['slideshow.css']},
install_requires = ['numpy', 'future'],
tests_require = ['pytest'],
# define optional dependencies here, so that they can be installed
# for example using the "pip -e MDP[scipy] syntax"
extras_require = {'pp' : 'pp',
'joblib' : 'joblib',
'scikit-learn' : 'scikit-learn',
'scipy' : 'scipy',
'libsvm' : 'libsvm',
'pytest': 'pytest'},
cmdclass = {'test': MDPTest}
)
if __name__ == '__main__':
setup_package()