Skip to content

Commit 6a47383

Browse files
authored
Determine the minimum required versions of dependencies from package metadata for docs (#3380)
1 parent 8d12796 commit 6a47383

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

doc/conf.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@
33
"""
44

55
import datetime
6-
from importlib.metadata import metadata
6+
import importlib
77

8-
# ruff: isort: off
9-
from sphinx_gallery.sorting import ExplicitOrder, ExampleTitleSortKey
10-
from pygmt.clib import required_gmt_version
8+
from packaging.requirements import Requirement
119
from pygmt import __commit__, __version__
10+
from pygmt.clib import required_gmt_version
1211
from pygmt.sphinx_gallery import PyGMTScraper
12+
from sphinx_gallery.sorting import ExampleTitleSortKey, ExplicitOrder
1313

14-
# ruff: isort: on
15-
16-
requires_python = metadata("pygmt")["Requires-Python"]
17-
requires_gmt = f">={required_gmt_version}"
14+
# Dictionary for dependency name and minimum required version.
15+
requirements = {
16+
Requirement(requirement).name: str(Requirement(requirement).specifier)
17+
for requirement in importlib.metadata.requires("pygmt")
18+
}
19+
requirements.update(
20+
{
21+
"python": importlib.metadata.metadata("pygmt")["Requires-Python"],
22+
"gmt": f">={required_gmt_version}",
23+
}
24+
)
1825

1926
extensions = [
2027
"myst_parser",
@@ -51,8 +58,7 @@
5158
]
5259
# These enable substitutions using {{ key }} in the Markdown files
5360
myst_substitutions = {
54-
"requires_python": requires_python,
55-
"requires_gmt": requires_gmt,
61+
"requires": requirements,
5662
}
5763

5864

doc/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ development version.
5959

6060
## Which Python?
6161

62-
PyGMT is tested to run on Python {{ requires_python }}.
62+
PyGMT is tested to run on Python {{ requires.python }}.
6363

6464
We recommend using the [Miniforge](https://github.com/conda-forge/miniforge#miniforge3)
6565
Python distribution to ensure you have all dependencies installed and
@@ -69,7 +69,7 @@ your computer and doesn't interfere with any other Python installations on your
6969

7070
## Which GMT?
7171

72-
PyGMT requires Generic Mapping Tools (GMT) {{ requires_gmt }} since there are many
72+
PyGMT requires Generic Mapping Tools (GMT) {{ requires.gmt }} since there are many
7373
changes being made to GMT itself in response to the development of PyGMT.
7474

7575
Compiled conda packages of GMT for Linux, macOS and Windows are provided through

doc/minversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ after their initial release.
1212

1313
| PyGMT Version | GMT | Python | NumPy | Pandas | Xarray |
1414
|---|---|---|---|---|---|
15-
| [Dev][]* [[Docs][Docs Dev]] | >=6.3.0 | >=3.10 | >=1.24 | >=1.5 | >=2022.09 |
15+
| [Dev][]* [[Docs][Docs Dev]] | {{ requires.gmt }} | {{ requires.python }} | {{ requires.numpy }} | {{ requires.pandas }} | {{ requires.xarray }} |
1616
| [v0.12.0][] [[Docs][Docs v0.12.0]] | >=6.3.0 | >=3.10 | >=1.23 | >=1.5 | >=2022.06 |
1717
| [v0.11.0][] [[Docs][Docs v0.11.0]] | >=6.3.0 | >=3.9 | >=1.23 | | |
1818
| [v0.10.0][] [[Docs][Docs v0.10.0]] | >=6.3.0 | >=3.9 | >=1.22 | | |

0 commit comments

Comments
 (0)