-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
177 lines (145 loc) · 4.95 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
from __future__ import print_function
import os
import shutil
from os.path import dirname, join
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from setuptools.command.develop import develop as _develop
from setuptools.command.install import install as _install
REQUIREMENTS_TESTS = [
'pytest>=2.6.4',
'pytest-cov>=1.8.1',
'mock>=2.0.0',
'virtualenv>=15.0.1',
'tox>=2.2.0',
]
def _get_version():
"""Return the project version from VERSION file."""
with open(join(dirname(__file__), 'marvin_automl_engine/VERSION'), 'rb') as f:
version = f.read().decode('ascii').strip()
return version
def _hooks(dir):
_set_autocomplete()
_install_notebook_extension()
def _set_autocomplete():
import marvin_python_toolbox as toolbox
virtualenv = os.environ.get('VIRTUAL_ENV', None)
if virtualenv:
postactivate = os.path.join(virtualenv, 'bin', 'postactivate')
if os.path.exists(postactivate):
shutil.copy(
os.path.join(toolbox.__path__[0], 'extras', 'marvin_bash_completion'),
os.path.join(virtualenv, 'marvin_bash_completion')
)
command = 'source "{}"'.format(os.path.join(virtualenv, 'marvin_bash_completion'))
with open(postactivate, 'r+') as fp:
lines = fp.readlines()
fp.seek(0)
configured = False
for line in lines:
if 'marvin_bash_completion' in line:
# Replacing old autocomplete configuration
fp.write(command)
configured = True
else:
fp.write(line)
if not configured:
fp.write(command)
# 'Autocomplete was successfully configured'
fp.write('\n')
fp.truncate()
def _install_notebook_extension():
import marvin_python_toolbox as toolbox
install_command = [
"jupyter",
"nbextension",
"install",
os.path.join(toolbox.__path__[0], 'extras', 'notebook_extensions', 'main.js'),
"--destination",
"marvin.js",
"--sys-prefix",
"--overwrite"
]
os.system(' '.join(install_command))
enable_command = [
"jupyter",
"nbextension",
"enable",
"marvin",
"--sys-prefix"
]
os.system(' '.join(enable_command))
class develop(_develop):
def run(self):
_develop.run(self)
self.execute(_hooks, (self.install_lib,), msg="Running develop preparation task")
class install(_install):
def run(self):
_install.run(self)
self.execute(_hooks, (self.install_lib,), msg="Running install preparation task")
class Tox(TestCommand):
"""Run the test cases using TOX command."""
user_options = [('tox-args=', 'a', "Arguments to pass to tox")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.tox_args = None
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
# Import here, cause outside the eggs aren't loaded
import tox
import shlex
import sys
args = self.tox_args
if args:
args = shlex.split(self.tox_args)
else:
# Run all tests by default
args = ['-c', join(dirname(__file__), 'tox.ini'), 'tests']
errno = tox.cmdline(args=args)
sys.exit(errno)
setup(
name='marvin_automl_engine',
version=_get_version(),
url='',
description='Marvin engine',
long_description=open(join(dirname(__file__), 'README.md')).read(),
author='Marvin AI Community',
maintainer='Marvin AI Community',
maintainer_email='marvin-ai@googlegroups.com',
packages=find_packages(exclude=('tests', 'tests.*')),
include_package_data=True,
zip_safe=False,
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=[
'scikit-learn',
'scipy==0.19.1',
'numpy==1.13.1',
'pandas==0.20.3',
'matplotlib==2.0.2',
'marvin-python-toolbox==0.0.4',
'Fabric==1.14.0',
'tpot==0.9.3',
'datacleaner==0.1.5',
],
tests_require=REQUIREMENTS_TESTS,
extras_require={
'testing': REQUIREMENTS_TESTS,
},
cmdclass={
'test': Tox, 'develop': develop, 'install': install
},
)