From b99d5c87383e540a802d2a192a27ca3053ee4dbd Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Thu, 17 Feb 2022 16:13:03 -0500 Subject: [PATCH] Add `pyproject.toml` file (#11323) --- ceph/MANIFEST.in | 10 ------- ceph/pyproject.toml | 62 ++++++++++++++++++++++++++++++++++++++++++++ ceph/requirements.in | 1 - ceph/setup.py | 19 ++++++++++++-- ceph/tox.ini | 2 +- 5 files changed, 80 insertions(+), 14 deletions(-) delete mode 100644 ceph/MANIFEST.in create mode 100644 ceph/pyproject.toml delete mode 100644 ceph/requirements.in diff --git a/ceph/MANIFEST.in b/ceph/MANIFEST.in deleted file mode 100644 index 6fa1c2388a4eb..0000000000000 --- a/ceph/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/ceph/pyproject.toml b/ceph/pyproject.toml new file mode 100644 index 0000000000000..61660721ed74b --- /dev/null +++ b/ceph/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = [ + "hatchling>=0.11.2", + "setuptools; python_version < '3.0'", +] +build-backend = "hatchling.build" + +[project] +name = "datadog-ceph" +description = "The Ceph check" +readme = "README.md" +license = "BSD-3-Clause" +keywords = [ + "datadog", + "datadog agent", + "datadog check", + "ceph", +] +authors = [ + { name = "Datadog", email = "packages@datadoghq.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.2.0", +] +dynamic = [ + "version", +] + +[project.optional-dependencies] +deps = [] + +[project.urls] +Source = "https://github.com/DataDog/integrations-core" + +[tool.hatch.version] +path = "datadog_checks/ceph/__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/ceph/requirements.in b/ceph/requirements.in deleted file mode 100644 index 8b137891791fe..0000000000000 --- a/ceph/requirements.in +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ceph/setup.py b/ceph/setup.py index defcd7a3a7de9..577984e6f5718 100644 --- a/ceph/setup.py +++ b/ceph/setup.py @@ -26,7 +26,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( name='datadog-ceph', @@ -58,7 +73,7 @@ def get_dependencies(): packages=['datadog_checks.ceph'], # 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/ceph/tox.ini b/ceph/tox.ini index 2530828e6a746..34ea853eefdb8 100644 --- a/ceph/tox.ini +++ b/ceph/tox.ini @@ -14,6 +14,7 @@ description = dd_check_style = true usedevelop = true platform = linux|darwin|win32 +extras = deps deps = -e../datadog_checks_base[deps] -rrequirements-dev.txt @@ -24,5 +25,4 @@ passenv = DOCKER* COMPOSE* commands = - pip install -r requirements.in pytest -v {posargs}