forked from DataDog/integrations-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
85 lines (71 loc) · 2.58 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
# (C) Datadog, Inc. 2018-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from codecs import open # To use a consistent encoding
from os import path
from setuptools import setup
HERE = path.abspath(path.dirname(__file__))
ABOUT = {}
with open(path.join(HERE, "datadog_checks", "base", "__about__.py")) as f:
exec(f.read(), ABOUT)
# Get the long description from the README file
LONG_DESC = ""
with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
LONG_DESC = f.read()
def get_requirements(fpath, exclude=None, only=None):
if exclude is None:
exclude = []
if only is None:
only = []
with open(path.join(HERE, fpath), encoding='utf-8') as f:
requirements = []
for line in f:
name = line.split("==")[0]
if only:
if name in only:
requirements.append(line.rstrip())
else:
if name not in exclude:
requirements.append(line.rstrip())
return requirements
def parse_pyproject_array(name):
import os
import re
from ast import literal_eval
pattern = r'^{} = (\[.+?\])$'.format(name)
with open(os.path.join(HERE, 'pyproject.toml'), 'r', encoding='utf-8') as f:
# Windows \r\n prevents match
contents = '\n'.join(line.rstrip() for line in f.readlines())
array = re.search(pattern, contents, flags=re.MULTILINE | re.DOTALL).group(1)
return literal_eval(array)
setup(
# Version should always match one from an agent release
version=ABOUT["__version__"],
name='datadog-checks-base',
description='The Datadog Check Toolkit',
long_description=LONG_DESC,
long_description_content_type='text/markdown',
keywords='datadog agent checks',
url='https://github.com/DataDog/integrations-core',
author='Datadog',
author_email='packages@datadoghq.com',
license='BSD',
# See https://pypi.org/classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: System :: Monitoring',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.9',
],
packages=['datadog_checks'],
include_package_data=True,
extras_require={
'deps': parse_pyproject_array('deps'),
'db': parse_pyproject_array('db'),
'http': parse_pyproject_array('http'),
'json': parse_pyproject_array('json'),
'kube': parse_pyproject_array('kube'),
},
)