Skip to content

Commit 5e4922e

Browse files
committed
refactor: use pyproject.toml
Also includes: - Bump to the min python-dateutil version to bring it into line w/ our doc dependencies - Adding @gadomski as a maintainer - Remove the unused, undocumented `validation` extra - Rework the min_requirement CI check
1 parent 47b7f35 commit 5e4922e

File tree

12 files changed

+167
-210
lines changed

12 files changed

+167
-210
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,19 @@ jobs:
2424
- macos-latest
2525
steps:
2626
- uses: actions/checkout@v3
27-
2827
- name: Set up Python ${{ matrix.python-version }}
2928
uses: actions/setup-python@v4
3029
with:
3130
python-version: ${{ matrix.python-version }}
3231
cache: "pip"
33-
cache-dependency-path: |
34-
setup.py
35-
requirements-dev.txt
36-
37-
- name: Install package
38-
run: pip install .
39-
40-
- name: Install dev requirements
41-
run: pip install -r requirements-dev.txt
42-
32+
- name: Install package with dev requirements
33+
run: pip install .[dev]
4334
- name: Run pre-commit
4435
run: pre-commit run --all-files
45-
4636
- name: Run pytest
4737
run: pytest -Werror -s --block-network --cov pystac_client --cov-report term-missing
48-
4938
- name: Run coverage
5039
run: coverage xml
51-
5240
- name: Upload All coverage to Codecov
5341
uses: codecov/codecov-action@v3
5442
with:
@@ -65,15 +53,10 @@ jobs:
6553
with:
6654
python-version: 3.9
6755
cache: "pip"
68-
cache-dependency-path: "requirements-min.txt"
56+
- name: Install with dev requirements
57+
run: pip install .[dev]
6958
- name: Install minimum requirements
70-
run: pip install -r requirements-min.txt
71-
- name: Install
72-
run: pip install .
73-
- name: Install dev requirements
74-
run: pip install -r requirements-dev.txt
75-
- name: Check minimum requirements
76-
run: scripts/check-minimum-requirements
59+
run: ./scripts/install-min-requirements
7760
- name: Test
7861
run: ./scripts/test
7962

@@ -109,13 +92,10 @@ jobs:
10992
with:
11093
python-version: 3.9
11194
cache: "pip"
112-
cache-dependency-path: "setup.py"
11395
- name: Install
114-
run: pip install .
96+
run: pip install .[dev]
11597
- name: Install any pre-releases of pystac
11698
run: pip install -U --pre pystac
117-
- name: Install dev requirements
118-
run: pip install -r requirements-dev.txt
11999
- name: Test
120100
run: ./scripts/test
121101

@@ -128,8 +108,5 @@ jobs:
128108
with:
129109
python-version: 3.9
130110
cache: "pip"
131-
cache-dependency-path: "setup.py"
132111
- name: Install
133-
run: pip install .
134-
- name: Install dev and docs requirements
135-
run: pip install -r requirements-dev.txt -r requirements-docs.txt
112+
run: pip install .[dev,docs]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
- Switched to Ruff from isort/flake8 [#457](https://github.com/stac-utils/pystac-client/pull/457)
1717
- Move to `FutureWarning` from `DeprecationWarning` for item search interface functions that are to be removed [#464](https://github.com/stac-utils/pystac-client/pull/464)
1818
- Consolidate contributing docs into one place [#478](https://github.com/stac-utils/pystac-client/issues/478)
19+
- Use `pyproject.toml` instead of `setup.py` [#501](https://github.com/stac-utils/pystac-client/pull/501)
1920

2021
### Fixed
2122

docs/contributing.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ the library as an "editable link", then install the development dependencies:
1414
1515
$ git clone [email protected]:your_user_name/pystac-client.git
1616
$ cd pystac
17-
$ pip install -e .
18-
$ pip install -r requirements-dev.txt
17+
$ pip install -e '.[dev]'
1918
2019
Testing
2120
^^^^^^^
@@ -102,7 +101,7 @@ Python documentation requirements via pip, then use the ``build-docs`` script:
102101

103102
.. code-block:: bash
104103
105-
$ pip install -r requirements-docs.txt
104+
$ pip install -e '.[docs]'
106105
$ scripts/build-docs
107106
108107
CHANGELOG

docs/environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ dependencies:
99
- python=3.9
1010
- pip
1111
- pip:
12-
- -r ../requirements-docs.txt
13-
- -e ../
12+
- -e ../[docs]

pyproject.toml

Lines changed: 113 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,119 @@
1-
[tool.ruff]
2-
ignore = [
3-
"E722",
4-
"E731",
1+
[project]
2+
name = "pystac-client"
3+
description = "Python library for working with SpatioTemporal Asset Catalog (STAC) APIs."
4+
readme = "README.md"
5+
authors = [
6+
{ name = "Jon Duckworth", email = "[email protected]" },
7+
{ name = "Matthew Hanson", email = "[email protected]" },
58
]
6-
line-length = 88
7-
select = [
8-
"E",
9-
"F",
10-
"W",
9+
maintainers = [{ name = "Pete Gadomski", email = "[email protected]" }]
10+
keywords = ["pystac", "imagery", "raster", "catalog", "STAC"]
11+
license = { text = "Apache-2.0" }
12+
classifiers = [
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.8",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Operating System :: OS Independent",
20+
"Natural Language :: English",
21+
"Development Status :: 4 - Beta",
22+
"Intended Audience :: Developers",
23+
"License :: OSI Approved :: MIT License",
24+
"Topic :: Scientific/Engineering :: GIS",
25+
"Topic :: Software Development :: Libraries",
26+
"Topic :: Software Development :: Libraries :: Python Modules",
27+
]
28+
requires-python = ">=3.8"
29+
dependencies = [
30+
"requests>=2.28.2",
31+
"pystac[validation]>=1.7.2",
32+
"python-dateutil>=2.8.2",
1133
]
34+
dynamic = ["version"]
35+
36+
[project.scripts]
37+
stac-client = "pystac_client.cli:cli"
38+
39+
[project.optional-dependencies]
40+
dev = [
41+
"black~=23.3.0",
42+
"codespell~=2.2.4",
43+
"coverage~=7.2",
44+
"doc8~=1.1.1",
45+
"importlib-metadata~=6.6.0",
46+
"mypy~=1.2",
47+
"orjson==3.8.10",
48+
"pre-commit==3.2.2",
49+
"pytest-benchmark~=4.0.0",
50+
"pytest-console-scripts~=1.3.1",
51+
"pytest-cov~=4.0.0",
52+
"pytest-recording~=0.12.2",
53+
"pytest~=7.3.1",
54+
"recommonmark~=0.7.1",
55+
"requests-mock~=1.10.0",
56+
"ruff==0.0.263",
57+
"tomli~=2.0; python_version<'3.11'",
58+
"types-python-dateutil~=2.8.19",
59+
"types-requests~=2.28.11",
60+
]
61+
docs = [
62+
"Sphinx~=6.2",
63+
"boto3~=1.26",
64+
"geojson~=3.0.1",
65+
"geopandas~=0.12.2",
66+
"hvplot~=0.8.3",
67+
"ipykernel~=6.22",
68+
"ipython~=8.12",
69+
"jinja2<4.0",
70+
"matplotlib~=3.7.1",
71+
"myst-parser~=1.0.0",
72+
"nbsphinx~=0.9",
73+
"pydata-sphinx-theme~=0.13",
74+
"pygeoif~=1.0",
75+
"sphinxcontrib-fulltoc~=1.2",
76+
]
77+
78+
[project.urls]
79+
homepage = "https://github.com/stac-utils/pystac-client"
80+
documentation = "https://pystac-client.readthedocs.io"
81+
repository = "https://github.com/stac-utils/pystac-client.git"
82+
changelog = "https://github.com/stac-utils/pystac-client/blob/main/CHANGELOG.md"
83+
discussions = "https://github.com/radiantearth/stac-spec/discussions/categories/stac-software"
84+
85+
[tool.setuptools.packages.find]
86+
include = ["pystac_client*"]
87+
exclude = ["tests*"]
88+
89+
[tool.setuptools.dynamic]
90+
version = { attr = "pystac_client.version.__version__" }
91+
92+
[tool.doc8]
93+
ignore-path = "docs/_build,docs/tutorials"
94+
max-line-length = 130
95+
96+
[tool.ruff]
97+
ignore = ["E722", "E731"]
98+
line-length = 88
99+
select = ["E", "F", "W"]
12100

13101
[tool.ruff.per-file-ignores]
14102
"__init__.py" = ["F401"]
15103
"test_item_search.py" = ["E501"]
104+
105+
[tool.pytest.ini_options]
106+
markers = "vcr: records network activity"
107+
addopts = "--benchmark-skip"
108+
109+
[tool.mypy]
110+
show_error_codes = true
111+
strict = true
112+
113+
[[tool.mypy.overrides]]
114+
module = ["jinja2"]
115+
ignore_missing_imports = true
116+
117+
[build-system]
118+
requires = ["setuptools>=61.0"]
119+
build-backend = "setuptools.build_meta"

requirements-dev.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

requirements-docs.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

requirements-min.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/check-minimum-requirements

Lines changed: 0 additions & 44 deletions
This file was deleted.

scripts/install-min-requirements

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
3+
"""Installs the minimum version of all stactools dependencies, with pip.
4+
5+
Assumptions:
6+
- You've installed the development dependencies: `pip install '.[dev]'`
7+
- All of the dependencies in pyproject.toml are specified with `>=`
8+
9+
For more context on the approach and rationale behind testing against minimum
10+
requirements, see
11+
https://www.gadom.ski/2022/02/18/dependency-protection-with-python-and-github-actions.html.
12+
13+
"""
14+
15+
import subprocess
16+
import sys
17+
from pathlib import Path
18+
19+
from packaging.requirements import Requirement
20+
21+
assert sys.version_info[0] == 3
22+
if sys.version_info[1] < 11:
23+
import tomli as toml
24+
else:
25+
import tomllib as toml
26+
27+
28+
root = Path(__file__).parents[1]
29+
with open(root / "pyproject.toml", "rb") as f:
30+
pyproject_toml = toml.load(f)
31+
requirements = []
32+
for install_requires in filter(
33+
bool,
34+
(i.strip() for i in pyproject_toml["project"]["dependencies"]),
35+
):
36+
requirement = Requirement(install_requires)
37+
assert len(requirement.specifier) == 1
38+
specifier = list(requirement.specifier)[0]
39+
assert specifier.operator == ">="
40+
install_requires = install_requires.replace(">=", "==")
41+
requirements.append(install_requires)
42+
43+
subprocess.run(["pip", "install", *requirements])

0 commit comments

Comments
 (0)