Skip to content

Commit

Permalink
add CI min-dependencies job
Browse files Browse the repository at this point in the history
  • Loading branch information
pjhartzell committed Aug 6, 2023
1 parent 87b6d8b commit bf2297a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ jobs:
run: pre-commit run --all-files
- name: Run tests
run: pytest
min-dependencies:
runs-on: ubuntu-latest
steps:
- name: Chekcout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: "pip"
- name: Install geos
run: sudo apt-get install libgeos-dev
- name: Install with dev dependencies
run: pip install .[dev]
- name: Install minimum versions of dependencies
run: scripts/install_min_dependencies
- name: Check with pre-commit
run: pre-commit run --all-files
- name: Run tests
run: pytest
docs:
runs-on: ubuntu-latest
defaults:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 2 - Pre-Alpha",
]
dependencies = ["rasterio", "shapely"]
dependencies = ["rasterio>=1.3", "shapely>=2.0"]

[project.optional-dependencies]
dev = [
Expand All @@ -21,6 +21,7 @@ dev = [
"pre-commit~=3.3",
"pytest~=7.4",
"ruff==0.0.282",
"tomli~=2.0; python_version<'3.11'",
]
docs = ["sphinx~=7.1", "pydata-sphinx-theme~=0.13"]

Expand Down
38 changes: 38 additions & 0 deletions scripts/install-min-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3

"""Installs the minimum version of all dependencies, with pip.
Assumptions:
- You've installed the development dependencies: `pip install '.[dev]'`
- All of the dependencies in pyproject.toml are specified with `>=`
"""

import subprocess
import sys
from pathlib import Path

from packaging.requirements import Requirement

assert sys.version_info[0] == 3
if sys.version_info[1] < 11:
import tomli as toml
else:
import tomllib as toml


root = Path(__file__).parents[1]
with open(root / "pyproject.toml", "rb") as f:
pyproject_toml = toml.load(f)
requirements = []
for install_requires in filter(
bool,
(i.strip() for i in pyproject_toml["project"]["dependencies"]),
):
requirement = Requirement(install_requires)
assert len(requirement.specifier) == 1
specifier = list(requirement.specifier)[0]
assert specifier.operator == ">="
install_requires = install_requires.replace(">=", "==")
requirements.append(install_requires)

subprocess.run(["pip", "install", *requirements], check=True)

0 comments on commit bf2297a

Please sign in to comment.