-
Notifications
You must be signed in to change notification settings - Fork 46
/
setup.py
118 lines (92 loc) · 2.91 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
#! /usr/bin/env python
"""Perform setup of the package for build."""
import io
import os
import re
import sys
from setuptools import Command
from setuptools.command.test import test as TestCommand
from setuptools import setup, find_packages
with io.open('eqllib/__init__.py', 'rt', encoding='utf8') as f:
__version__ = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1)
# Load utility functions directory for recursive globbing
with io.open('eqllib/utils.py', 'rt', encoding='utf8') as f:
exec(f.read())
class Lint(Command):
"""Wrapper for the standard linters."""
description = 'Lint the code'
user_options = []
def initialize_options(self):
"""Initialize options."""
def finalize_options(self):
"""Finalize options."""
def run(self):
"""Run the flake8 linter."""
self.distribution.fetch_build_eggs(test_requires)
self.distribution.packages.append('tests')
from flake8.main import Flake8Command
flake8cmd = Flake8Command(self.distribution)
flake8cmd.options_dict = {}
flake8cmd.run()
class Test(TestCommand):
"""Use pytest (http://pytest.org/latest/) in place of the standard unittest library."""
user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]
def initialize_options(self):
"""Need to ensure pytest_args exists."""
TestCommand.initialize_options(self)
self.pytest_args = []
def run_tests(self):
"""Run pytest."""
self.distribution.fetch_build_eggs(test_requires)
self.distribution.packages.append('tests')
import pytest
sys.exit(pytest.main(self.pytest_args))
def relative_glob(root, pattern):
for path in recursive_glob(root, pattern): # noqa: F821
yield os.path.relpath(os.path.join(path), 'eqllib')
extra_files = ['enterprise-attack.json.gz']
extra_files.extend(relative_glob('domains', '*.toml'))
extra_files.extend(relative_glob('analytics', '*.toml'))
extra_files.extend(relative_glob('sources', '*.toml'))
install_requires = [
"toml~=0.9",
"eql~=0.9.2",
"jsl~=0.2",
"jsonschema==2.6.0",
]
test_requires = [
"pytest~=3.8.2",
"pytest-cov==2.4",
"flake8==2.5.1",
"configparser<5.0; python_version<'3.4'",
"more-itertools~=5.0; python_version<'3.4'",
"zipp<1.0; python_version<'3.4'",
]
setup(
name='eqllib',
version=__version__,
description='EQL Analytics Library',
install_requires=install_requires,
cmdclass={
'lint': Lint,
'test': Test
},
extras_require={
'docs': [
"sphinx==1.7.9",
"sphinx_rtd_theme",
],
'test': test_requires
},
entry_points={
'console_scripts': [
'eqllib=eqllib.main:normalize_main',
],
},
package_data={
'eqllib': extra_files,
},
packages=find_packages(),
include_package_data=True,
zip_safe=False,
)