Skip to content

Commit

Permalink
Update templates for new integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Feb 16, 2022
1 parent 916a556 commit 292fcf4
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 45 deletions.
12 changes: 10 additions & 2 deletions datadog_checks_dev/datadog_checks/dev/tooling/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
write_file,
write_file_binary,
)
from .constants import integration_type_links
from .utils import get_config_models_documentation, get_license_header, kebab_case_name, normalize_package_name
from .constants import REPO_CHOICES, integration_type_links
from .utils import (
get_config_models_documentation,
get_license_header,
kebab_case_name,
normalize_package_name,
normalize_project_name,
)

TEMPLATES_DIR = path_join(os.path.dirname(os.path.abspath(__file__)), 'templates', 'integration')
BINARY_EXTENSIONS = ('.png',)
Expand Down Expand Up @@ -91,6 +97,7 @@ def construct_template_fields(integration_name, repo_choice, manifest_v2, integr
'author': author,
'check_class': f"{''.join(part.capitalize() for part in normalized_integration_name.split('_'))}Check",
'check_name': check_name,
'project_name': normalize_project_name(normalized_integration_name),
'documentation': get_config_models_documentation(),
'integration_name': integration_name,
'check_name_kebab': check_name_kebab,
Expand All @@ -100,6 +107,7 @@ def construct_template_fields(integration_name, repo_choice, manifest_v2, integr
'license_header': license_header,
'install_info': install_info,
'repo_choice': repo_choice,
'repo_name': REPO_CHOICES[repo_choice],
'manifest_v2': manifest_v2,
'support_type': support_type,
'test_dev_dep': test_dev_dep,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = [
"hatchling>=0.13.0",
"setuptools; python_version < '3.0'",
]
build-backend = "hatchling.build"

[project]
name = "datadog-{project_name}"
description = "The {integration_name} check"
readme = "README.md"
license = "BSD-3-Clause"
keywords = [
"datadog",
"datadog agent",
"datadog check",
"{check_name}",
]
authors = [
{{ name = "{author}", email = "{email_packages}" }},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.8",
"Topic :: System :: Monitoring",
]
dependencies = [
"datadog-checks-base>=11.2.0",
]
dynamic = [
"version",
]

[project.optional-dependencies]
deps = []

[project.urls]
Source = "https://github.com/DataDog/{repo_name}"

[tool.hatch.version]
path = "datadog_checks/{check_name}/__about__.py"

[tool.hatch.build.targets.sdist]
include = [
"/datadog_checks",
"/tests",
"/manifest.json",
"/requirements-dev.txt",
"/tox.ini",
]

[tool.hatch.build.targets.wheel]
include = [
"/datadog_checks",
]
dev-mode-dirs = [
".",
]
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ def get_dependencies():
return f.readlines()


CHECKS_BASE_REQ = 'datadog-checks-base>=11.2.0'
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)


CHECKS_BASE_REQ = parse_pyproject_array('dependencies')[0]


setup(
Expand All @@ -34,7 +49,9 @@ def get_dependencies():
description='The {integration_name} check',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='datadog agent {check_name} check',{package_url}
keywords='datadog agent {check_name} check',
# The project's main homepage.
url='https://github.com/DataDog/{repo_name}',
# Author details
author='{author}',
author_email='{email_packages}',
Expand All @@ -54,7 +71,7 @@ def get_dependencies():
packages=['datadog_checks.{check_name}'],
# Run-time dependencies
install_requires=[CHECKS_BASE_REQ],
extras_require={{'deps': get_dependencies()}},
extras_require={{'deps': parse_pyproject_array('deps')}},
# Extra files to ship with the wheel package
include_package_data=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ envdir =
dd_check_style = true
usedevelop = true
platform = linux|darwin|win32
extras = deps
deps =
{tox_base_dep}
-rrequirements-dev.txt
passenv =
DOCKER*
COMPOSE*
commands =
pip install -r requirements.in
pytest -v {{posargs}}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = [
"hatchling>=0.13.0",
"setuptools; python_version < '3.0'",
]
build-backend = "hatchling.build"

[project]
name = "datadog-{project_name}"
description = "The {integration_name} check"
readme = "README.md"
license = "BSD-3-Clause"
keywords = [
"datadog",
"datadog agent",
"datadog check",
"{check_name}",
]
authors = [
{{ name = "{author}", email = "{email_packages}" }},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.8",
"Topic :: System :: Monitoring",
]
dependencies = [
"datadog-checks-base>=23.6.0",
]
dynamic = [
"version",
]

[project.optional-dependencies]
deps = []

[project.urls]
Source = "https://github.com/DataDog/{repo_name}"

[tool.hatch.version]
path = "datadog_checks/{check_name}/__about__.py"

[tool.hatch.build.targets.sdist]
include = [
"/datadog_checks",
"/tests",
"/manifest.json",
"/requirements-dev.txt",
"/tox.ini",
]

[tool.hatch.build.targets.wheel]
include = [
"/datadog_checks",
]
dev-mode-dirs = [
".",
]
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ def get_dependencies():
return f.readlines()


CHECKS_BASE_REQ = 'datadog-checks-base>=23.6.0'
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)


CHECKS_BASE_REQ = parse_pyproject_array('dependencies')[0]


setup(
Expand All @@ -36,7 +51,7 @@ def get_dependencies():
long_description_content_type='text/markdown',
keywords='datadog agent {check_name} check',
# The project's main homepage.
url='https://github.com/DataDog/integrations-{repo_choice}',
url='https://github.com/DataDog/{repo_name}',
# Author details
author='{author}',
author_email='{email_packages}',
Expand All @@ -56,7 +71,7 @@ def get_dependencies():
packages=['datadog_checks.{check_name}'],
# Run-time dependencies
install_requires=[CHECKS_BASE_REQ],
extras_require={{'deps': get_dependencies()}},
extras_require={{'deps': parse_pyproject_array('deps')}},
# Extra files to ship with the wheel package
include_package_data=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ minversion = 2.0
skip_missing_interpreters = true
basepython = py38
envlist =
py{{27,38}}
py38

[testenv]
ensure_default_envdir = true
envdir =
py27: {{toxworkdir}}/py27
py38: {{toxworkdir}}/py38
description =
py{{27,38}}: e2e ready
py38: e2e ready
dd_check_style = true
usedevelop = true
platform = linux|darwin|win32
extras = deps
deps =
{tox_base_dep}
passenv =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = [
"hatchling>=0.13.0",
"setuptools; python_version < '3.0'",
]
build-backend = "hatchling.build"

[project]
name = "datadog-{project_name}"
description = "The {integration_name} check"
readme = "README.md"
license = "BSD-3-Clause"
keywords = [
"datadog",
"datadog agent",
"datadog check",
"{check_name}",
]
authors = [
{{ name = "{author}", email = "{email_packages}" }},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.8",
"Topic :: System :: Monitoring",
]
dependencies = [
"datadog-checks-base>=11.2.0",
]
dynamic = [
"version",
]

[project.optional-dependencies]
deps = []

[project.urls]
Source = "https://github.com/DataDog/{repo_name}"

[tool.hatch.version]
path = "datadog_checks/{check_name}/__about__.py"

[tool.hatch.build.targets.sdist]
include = [
"/datadog_checks",
"/tests",
"/manifest.json",
"/requirements-dev.txt",
"/tox.ini",
]

[tool.hatch.build.targets.wheel]
include = [
"/datadog_checks",
]
dev-mode-dirs = [
".",
]
Empty file.
Loading

0 comments on commit 292fcf4

Please sign in to comment.