Skip to content

Commit

Permalink
refactor: use pyproject.toml
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gadomski committed Apr 27, 2023
1 parent 47b7f35 commit 3025bcb
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 208 deletions.
37 changes: 7 additions & 30 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,19 @@ jobs:
- macos-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
requirements-dev.txt
- name: Install package
run: pip install .

- name: Install dev requirements
run: pip install -r requirements-dev.txt

- name: Install package with dev requirements
run: pip install .[dev]
- name: Run pre-commit
run: pre-commit run --all-files

- name: Run pytest
run: pytest -Werror -s --block-network --cov pystac_client --cov-report term-missing

- name: Run coverage
run: coverage xml

- name: Upload All coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand All @@ -65,15 +53,10 @@ jobs:
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: "requirements-min.txt"
- name: Install with dev requirements
run: pip install .[dev]
- name: Install minimum requirements
run: pip install -r requirements-min.txt
- name: Install
run: pip install .
- name: Install dev requirements
run: pip install -r requirements-dev.txt
- name: Check minimum requirements
run: scripts/check-minimum-requirements
run: ./scripts/install-min-requirements
- name: Test
run: ./scripts/test

Expand Down Expand Up @@ -109,13 +92,10 @@ jobs:
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: "setup.py"
- name: Install
run: pip install .
run: pip install .[dev]
- name: Install any pre-releases of pystac
run: pip install -U --pre pystac
- name: Install dev requirements
run: pip install -r requirements-dev.txt
- name: Test
run: ./scripts/test

Expand All @@ -128,8 +108,5 @@ jobs:
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: "setup.py"
- name: Install
run: pip install .
- name: Install dev and docs requirements
run: pip install -r requirements-dev.txt -r requirements-docs.txt
run: pip install .[dev,docs]
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Switched to Ruff from isort/flake8 [#457](https://github.com/stac-utils/pystac-client/pull/457)
- 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)
- Consolidate contributing docs into one place [#478](https://github.com/stac-utils/pystac-client/issues/478)
- Use `pyproject.toml` instead of `setup.py` [#501](https://github.com/stac-utils/pystac-client/pull/501)

### Fixed

Expand Down
5 changes: 2 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ the library as an "editable link", then install the development dependencies:
$ git clone git@github.com:your_user_name/pystac-client.git
$ cd pystac
$ pip install -e .
$ pip install -r requirements-dev.txt
$ pip install -e '.[dev]'
Testing
^^^^^^^
Expand Down Expand Up @@ -102,7 +101,7 @@ Python documentation requirements via pip, then use the ``build-docs`` script:

.. code-block:: bash
$ pip install -r requirements-docs.txt
$ pip install -e '.[docs]'
$ scripts/build-docs
CHANGELOG
Expand Down
119 changes: 110 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,116 @@
[tool.ruff]
ignore = [
"E722",
"E731",
[project]
name = "pystac-client"
description = "Python library for working with SpatioTemporal Asset Catalog (STAC) APIs."
readme = "README.md"
authors = [
{ name = "Jon Duckworth", email = "duckontheweb@gmail.com" },
{ name = "Matthew Hanson", email = "matt.a.hanson@gmail.com" },
]
line-length = 88
select = [
"E",
"F",
"W",
maintainers = [{ name = "Pete Gadomski", email = "pete.gadomski@gmail.com" }]
keywords = ["pystac", "imagery", "raster", "catalog", "STAC"]
license = { text = "Apache-2.0" }
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"Natural Language :: English",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"
dependencies = [
"requests>=2.28.2",
"pystac[validation]>=1.7.2",
"python-dateutil>=2.8.2",
]
dynamic = ["version"]

[project.optional-dependencies]
dev = [
"black~=23.3.0",
"codespell~=2.2.4",
"coverage~=7.2",
"doc8~=1.1.1",
"importlib-metadata~=6.6.0",
"mypy~=1.2",
"orjson==3.8.10",
"pre-commit==3.2.2",
"pytest-benchmark~=4.0.0",
"pytest-console-scripts~=1.3.1",
"pytest-cov~=4.0.0",
"pytest-recording~=0.12.2",
"pytest~=7.3.1",
"recommonmark~=0.7.1",
"requests-mock~=1.10.0",
"ruff==0.0.263",
"tomli~=2.0; python_version<'3.11'",
"types-python-dateutil~=2.8.19",
"types-requests~=2.28.11",
]
docs = [
"Sphinx~=6.2",
"boto3~=1.26",
"geojson~=3.0.1",
"geopandas~=0.12.2",
"hvplot~=0.8.3",
"ipykernel~=6.22",
"ipython~=8.12",
"jinja2<4.0",
"matplotlib~=3.7.1",
"myst-parser~=1.0.0",
"nbsphinx~=0.9",
"pydata-sphinx-theme~=0.13",
"pygeoif~=1.0",
"sphinxcontrib-fulltoc~=1.2",
]

[project.urls]
homepage = "https://github.com/stac-utils/pystac-client"
documentation = "https://pystac-client.readthedocs.io"
repository = "https://github.com/stac-utils/pystac-client.git"
changelog = "https://github.com/stac-utils/pystac-client/blob/main/CHANGELOG.md"
discussions = "https://github.com/radiantearth/stac-spec/discussions/categories/stac-software"

[tool.setuptools.packages.find]
include = ["pystac_client*"]
exclude = ["tests*"]

[tool.setuptools.dynamic]
version = { attr = "pystac_client.version.__version__" }

[tool.doc8]
ignore-path = "docs/_build,docs/tutorials"
max-line-length = 130

[tool.ruff]
ignore = ["E722", "E731"]
line-length = 88
select = ["E", "F", "W"]

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"test_item_search.py" = ["E501"]

[tool.pytest]
markers = "vcr: records network activity"
addopts = "--benchmark-skip"

[tool.mypy]
show_error_codes = true
strict = true

[[tool.mypy.overrides]]
module = ["jinja2"]
ignore_missing_imports = true

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
19 changes: 0 additions & 19 deletions requirements-dev.txt

This file was deleted.

14 changes: 0 additions & 14 deletions requirements-docs.txt

This file was deleted.

3 changes: 0 additions & 3 deletions requirements-min.txt

This file was deleted.

44 changes: 0 additions & 44 deletions scripts/check-minimum-requirements

This file was deleted.

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

"""Installs the minimum version of all stactools dependencies, with pip.
Assumptions:
- You've installed the development dependencies: `pip install '.[dev]'`
- All of the dependencies in pyproject.toml are specified with `>=`
For more context on the approach and rationale behind testing against minimum
requirements, see
https://www.gadom.ski/2022/02/18/dependency-protection-with-python-and-github-actions.html.
"""

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])
25 changes: 0 additions & 25 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 3025bcb

Please sign in to comment.