diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/create.py b/datadog_checks_dev/datadog_checks/dev/tooling/create.py index 8acef1a004552..fd0df7948e086 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/create.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/create.py @@ -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',) @@ -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, @@ -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, diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/MANIFEST.in b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/MANIFEST.in deleted file mode 100644 index 6fa1c2388a4eb..0000000000000 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/MANIFEST.in +++ /dev/null @@ -1,10 +0,0 @@ -graft datadog_checks -graft tests - -include MANIFEST.in -include README.md -include requirements.in -include requirements-dev.txt -include manifest.json - -global-exclude *.py[cod] __pycache__ diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/pyproject.toml b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/pyproject.toml new file mode 100644 index 0000000000000..314c543186d6c --- /dev/null +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/pyproject.toml @@ -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 = [ + ".", +] diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/requirements.in b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/requirements.in deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/setup.py b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/setup.py index b5e8bf78b68c6..ccd92abe3d512 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/setup.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/setup.py @@ -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( @@ -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}', @@ -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, ) diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/tox.ini b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/tox.ini index 0fb319073fe04..e311c4d83a845 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/tox.ini +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/check/{check_name}/tox.ini @@ -13,6 +13,7 @@ envdir = dd_check_style = true usedevelop = true platform = linux|darwin|win32 +extras = deps deps = {tox_base_dep} -rrequirements-dev.txt @@ -20,5 +21,4 @@ passenv = DOCKER* COMPOSE* commands = - pip install -r requirements.in pytest -v {{posargs}} diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/MANIFEST.in b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/MANIFEST.in deleted file mode 100644 index dc7e373b08510..0000000000000 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -graft datadog_checks - -include MANIFEST.in -include README.md -include manifest.json - -global-exclude *.py[cod] __pycache__ diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/pyproject.toml b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/pyproject.toml new file mode 100644 index 0000000000000..1424858bd75dd --- /dev/null +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/pyproject.toml @@ -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 = [ + ".", +] diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/setup.py b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/setup.py index 901ed45e0c71e..ccd92abe3d512 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/setup.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/setup.py @@ -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( @@ -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}', @@ -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, ) diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/tox.ini b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/tox.ini index 0a3b26bc3611d..9ba5e0621cc6d 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/tox.ini +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/jmx/{check_name}/tox.ini @@ -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 = diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/MANIFEST.in b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/MANIFEST.in deleted file mode 100644 index 6fa1c2388a4eb..0000000000000 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/MANIFEST.in +++ /dev/null @@ -1,10 +0,0 @@ -graft datadog_checks -graft tests - -include MANIFEST.in -include README.md -include requirements.in -include requirements-dev.txt -include manifest.json - -global-exclude *.py[cod] __pycache__ diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/pyproject.toml b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/pyproject.toml new file mode 100644 index 0000000000000..314c543186d6c --- /dev/null +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/pyproject.toml @@ -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 = [ + ".", +] diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/requirements.in b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/requirements.in deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/setup.py b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/setup.py index fa7c5407ad15f..ccd92abe3d512 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/setup.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/templates/integration/logs/{check_name}/setup.py @@ -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( @@ -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}', @@ -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, )