/
setup.py
98 lines (80 loc) · 2.57 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
import os
import sys
import subprocess
import setuptools
from setuptools.command.build_ext import build_ext
from setuptools.command.test import test
class TestCommand(test):
description = 'run tests, linters and create a coverage report'
user_options = []
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.returncode = 0
def finalize_options(self):
super().finalize_options()
# New setuptools don't need this anymore, thus the try block.
try:
# pylint: disable=attribute-defined-outside-init
self.test_args = []
self.test_suite = 'True'
except AttributeError:
pass
def run_tests(self):
self._call('python -m pytest --cov=layered test')
self._call('python -m pylint layered')
self._call('python -m pylint test')
self._call('python -m pylint setup.py')
self._check()
def _call(self, command):
env = os.environ.copy()
env['PYTHONPATH'] = ''.join(':' + x for x in sys.path)
print('Run command', command)
try:
subprocess.check_call(command.split(), env=env)
except subprocess.CalledProcessError as error:
print('Command failed with exit code', error.returncode)
self.returncode = 1
def _check(self):
if self.returncode:
sys.exit(self.returncode)
class BuildExtCommand(build_ext):
"""
Fix Numpy build error when bundled as a dependency.
From http://stackoverflow.com/a/21621689/1079110
"""
def finalize_options(self):
super().finalize_options()
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
DESCRIPTION = 'Clean reference implementation of feed forward neural networks'
SETUP_REQUIRES = [
'numpy',
'sphinx',
]
INSTALL_REQUIRES = [
'PyYAML',
'numpy',
'matplotlib',
]
TESTS_REQUIRE = [
'pytest',
'pytest-cov',
'pylint',
]
if __name__ == '__main__':
setuptools.setup(
name='layered',
version='0.1.6',
description=DESCRIPTION,
url='http://github.com/danijar/layered',
author='Danijar Hafner',
author_email='mail@danijar.com',
license='MIT',
packages=['layered'],
setup_requires=SETUP_REQUIRES,
install_requires=INSTALL_REQUIRES,
tests_require=TESTS_REQUIRE,
cmdclass={'test': TestCommand, 'build_ext': BuildExtCommand},
entry_points={'console_scripts': ['layered=layered.__main__:main']},
)