Skip to content

Commit

Permalink
ci: check the min requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Mar 22, 2023
1 parent d2ce038 commit 53d958b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 13 additions & 17 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions scripts/check-minimum-requirements
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down

0 comments on commit 53d958b

Please sign in to comment.