From d0a0fae61e7704e9d37de722631b8eb02882bc2d Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 17 Mar 2022 12:44:47 -0400 Subject: [PATCH] Add `pyproject.toml` file (#1184) * Add `pyproject.toml` file * Use email from `manifest.json` --- redisenterprise/MANIFEST.in | 10 ------ redisenterprise/pyproject.toml | 62 +++++++++++++++++++++++++++++++++ redisenterprise/requirements.in | 0 redisenterprise/setup.py | 19 ++++++++-- redisenterprise/tox.ini | 2 +- 5 files changed, 80 insertions(+), 13 deletions(-) delete mode 100644 redisenterprise/MANIFEST.in create mode 100644 redisenterprise/pyproject.toml delete mode 100644 redisenterprise/requirements.in diff --git a/redisenterprise/MANIFEST.in b/redisenterprise/MANIFEST.in deleted file mode 100644 index 6fa1c2388a..0000000000 --- a/redisenterprise/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/redisenterprise/pyproject.toml b/redisenterprise/pyproject.toml new file mode 100644 index 0000000000..cbce8377d6 --- /dev/null +++ b/redisenterprise/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = [ + "hatchling>=0.12.0", + "setuptools; python_version < '3.0'", +] +build-backend = "hatchling.build" + +[project] +name = "datadog-redisenterprise" +description = "The Redis Enterprise check" +readme = "README.md" +license = "BSD-3-Clause" +keywords = [ + "datadog", + "datadog agent", + "datadog check", + "redisenterprise", +] +authors = [ + { email = "github@mague.com" }, +] +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.0.0", +] +dynamic = [ + "version", +] + +[project.optional-dependencies] +deps = [] + +[project.urls] +Source = "https://github.com/DataDog/integrations-extras" + +[tool.hatch.version] +path = "datadog_checks/redisenterprise/__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/redisenterprise", +] +dev-mode-dirs = [ + ".", +] diff --git a/redisenterprise/requirements.in b/redisenterprise/requirements.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/redisenterprise/setup.py b/redisenterprise/setup.py index e96a839ce6..0e7990c3ab 100644 --- a/redisenterprise/setup.py +++ b/redisenterprise/setup.py @@ -24,7 +24,22 @@ def get_dependencies(): return f.readlines() -CHECKS_BASE_REQ = 'datadog-checks-base>=11.0.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( @@ -55,7 +70,7 @@ def get_dependencies(): packages=['datadog_checks.redisenterprise'], # 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/redisenterprise/tox.ini b/redisenterprise/tox.ini index 2221002c3d..d83a95bb9e 100644 --- a/redisenterprise/tox.ini +++ b/redisenterprise/tox.ini @@ -13,6 +13,7 @@ envdir = dd_check_style = true usedevelop = true platform = linux|darwin|win32 +extras = deps deps = datadog-checks-base[deps]>=6.6.0 -rrequirements-dev.txt @@ -20,5 +21,4 @@ passenv = DOCKER* COMPOSE* commands = - pip install -r requirements.in pytest -v {posargs}