From 2245ee9f55f95f3b8ea52b7626ac296a7d6ae0bb Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Tue, 4 Apr 2023 12:30:38 -0400 Subject: [PATCH] Move testing dependencies to setup.cfg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch moves the packages listed in `tests/requirements.txt` into `setup.cfg`. This is done to: * Reduce complexity of downstream projects that wish to inherit testing dependencies. E.g. currently the `tests/requirements.txt` file is loaded via incorporating `case-utils` as a submodule in at least two projects (`case_exiftool`, `case_gnu_time`). * Expose test requirements for supply-chain review via package metadata. The feature name is for the test requirements is `testing`, inheriting the name from Python's `setuptools`. This feature is added knowing that, once added, it should not be removed, per this best practice in the PyPA guidance: > Best practice: if a project ends up no longer needing any other > packages to support a feature, it should keep an empty requirements > list for that feature in its extras_require argument, so that packages > depending on that feature don’t break (due to an invalid feature > name). There were no effects observed on Make-managed files. References: * https://github.com/casework/CASE-Implementation-ExifTool/blob/0.5.0/tests/Makefile#L43-L45 * https://github.com/casework/CASE-Implementation-GNU-Time/blob/0.7.0/tests/Makefile#L56-L58 * https://github.com/pypa/setuptools/blob/v67.6.1/setup.cfg#L42 * https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies Signed-off-by: Alex Nelson --- setup.cfg | 8 ++++++++ tests/Makefile | 8 ++------ tests/requirements.txt | 5 ----- 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 tests/requirements.txt diff --git a/setup.cfg b/setup.cfg index 7c0b0d9..e5ffda7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,6 +34,14 @@ console_scripts = case_sparql_select = case_utils.case_sparql_select:main case_validate = case_utils.case_validate:main +[options.extras_require] +testing = + PyLD + mypy + pytest + python-dateutil + types-python-dateutil + [options.package_data] case_utils = py.typed case_utils.ontology = diff --git a/tests/Makefile b/tests/Makefile index 0716d1a..c1c626e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -31,8 +31,7 @@ all: \ $(top_srcdir)/.git_submodule_init.done.log \ $(top_srcdir)/case_utils/__init__.py \ $(top_srcdir)/setup.cfg \ - $(top_srcdir)/setup.py \ - requirements.txt + $(top_srcdir)/setup.py rm -rf venv $(PYTHON3) -m venv \ venv @@ -42,14 +41,11 @@ all: \ pip \ setuptools \ wheel - source venv/bin/activate \ - && pip install \ - --requirement requirements.txt source venv/bin/activate \ && cd $(top_srcdir) \ && pip install \ --editable \ - . + .[testing] touch $@ all-case_utils: \ diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index f913d96..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -PyLD -mypy -pytest -python-dateutil -types-python-dateutil