From 53d958b7c2d295aa51d510d9ed40ac4fc05f5730 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 22 Mar 2023 04:19:20 -0600 Subject: [PATCH] ci: check the min requirements --- .github/workflows/continuous-integration.yml | 2 + requirements-dev.txt | 30 ++++++------- scripts/check-minimum-requirements | 44 ++++++++++++++++++++ setup.py | 2 +- 4 files changed, 60 insertions(+), 18 deletions(-) create mode 100755 scripts/check-minimum-requirements diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9cf3e9d4..be441409 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -70,6 +70,8 @@ jobs: run: pip install -r requirements-min.txt - name: Install run: pip install . + - name: Check minimum requirements + run: scripts/check-minimum-requirements - name: Install dev requirements run: pip install -r requirements-dev.txt - name: Test diff --git a/requirements-dev.txt b/requirements-dev.txt index d48d55dc..b6ed3581 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,23 +1,19 @@ -pytest~=7.2.2 +black~=23.1.0 +codespell~=2.2.4 +coverage~=7.2 +doc8~=1.1.1 +importlib-metadata~=6.1.0 +jsonschema~=4.17.3 +mypy~=1.1 +orjson==3.8.8 +pre-commit==3.2.0 pytest-benchmark~=4.0.0 +pytest-console-scripts~=1.3.1 pytest-cov~=4.0.0 pytest-recording~=0.12.2 -pytest-console-scripts~=1.3.1 +pytest~=7.2.2 recommonmark~=0.7.1 requests-mock~=1.10.0 - -mypy~=1.1 -types-requests~=2.28.11 -types-python-dateutil~=2.8.19 ruff==0.0.257 -black~=23.1.0 -codespell~=2.2.4 - -jsonschema~=4.17.3 -coverage~=7.2 -doc8~=1.1.1 - -pre-commit==3.2.0 - -# optional dependencies -orjson==3.8.8 +types-python-dateutil~=2.8.19 +types-requests~=2.28.11 diff --git a/scripts/check-minimum-requirements b/scripts/check-minimum-requirements new file mode 100755 index 00000000..cc4db6ac --- /dev/null +++ b/scripts/check-minimum-requirements @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +import sys +from pathlib import Path + +import importlib_metadata +from packaging.requirements import Requirement + +requirements_min = Path(__file__).parents[1] / "requirements-min.txt" +with open(requirements_min) as file: + min_requirements = [Requirement(line) for line in file] +min_requirements = dict( + (requirement.name, requirement) for requirement in min_requirements +) + +package_requirements = [ + Requirement(requirement) + for requirement in importlib_metadata.requires("pystac_client") +] +incorrect_requirements = list() +for package_requirement in package_requirements: + if package_requirement.marker is not None: + continue + if package_requirement.name not in min_requirements: + incorrect_requirements.append((package_requirement, None)) + continue + min_requirement = min_requirements[package_requirement.name] + for package_specifier, min_specifier in zip( + package_requirement.specifier, min_requirement.specifier + ): + if ( + package_specifier.operator == ">=" + and package_specifier.version != min_specifier.version + ): + incorrect_requirements.append((package_requirement, min_requirement)) + +if incorrect_requirements: + print("ERROR: Incorrect min-requirements.txt!") + for package_requirement, min_requirement in incorrect_requirements: + print(f"- package: {package_requirement}, min: {min_requirement}") + sys.exit(1) +else: + print("OK") + sys.exit(0) diff --git a/setup.py b/setup.py index a95c481f..68f6fc8b 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ package_data={"pystac_client": ["py.typed"]}, python_requires=">=3.8", install_requires=[ - "requests>=2.27.1", + "requests>=2.28.2", "pystac>=1.7.0", "python-dateutil>=2.7.0", ],