Skip to content

Commit 40545a0

Browse files
committed
Merge branch 'main' into python-3.13
2 parents f545e17 + 8b47baa commit 40545a0

21 files changed

+239
-155
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
# Checkout current git repository
3636
- name: Checkout
37-
uses: actions/[email protected].0
37+
uses: actions/[email protected].1
3838
with:
3939
# fetch all history so that setuptools-scm works
4040
fetch-depth: 0

.github/workflows/cache_data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
steps:
3737
# Checkout current git repository
3838
- name: Checkout
39-
uses: actions/[email protected].0
39+
uses: actions/[email protected].1
4040
with:
4141
# fetch all history so that setuptools-scm works
4242
fetch-depth: 0

.github/workflows/check-links.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323

2424
steps:
2525
- name: Checkout the repository
26-
uses: actions/[email protected].0
26+
uses: actions/[email protected].1
2727
with:
2828
path: repository
2929

3030
- name: Checkout the documentation
31-
uses: actions/[email protected].0
31+
uses: actions/[email protected].1
3232
with:
3333
ref: gh-pages
3434
path: documentation

.github/workflows/ci_docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
steps:
7070
# Checkout current git repository
7171
- name: Checkout
72-
uses: actions/[email protected].0
72+
uses: actions/[email protected].1
7373
with:
7474
# fetch all history so that setuptools-scm works
7575
fetch-depth: 0
@@ -139,7 +139,7 @@ jobs:
139139
run: make -C doc clean all
140140

141141
- name: Checkout the gh-pages branch
142-
uses: actions/[email protected].0
142+
uses: actions/[email protected].1
143143
with:
144144
ref: gh-pages
145145
# Checkout to this folder instead of the current one

.github/workflows/ci_doctests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
steps:
3636
# Checkout current git repository
3737
- name: Checkout
38-
uses: actions/[email protected].0
38+
uses: actions/[email protected].1
3939
with:
4040
# fetch all history so that setuptools-scm works
4141
fetch-depth: 0

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
steps:
104104
# Checkout current git repository
105105
- name: Checkout
106-
uses: actions/[email protected].0
106+
uses: actions/[email protected].1
107107
with:
108108
# fetch all history so that setuptools-scm works
109109
fetch-depth: 0

.github/workflows/ci_tests_dev.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
steps:
4747
# Checkout current git repository
4848
- name: Checkout
49-
uses: actions/[email protected].0
49+
uses: actions/[email protected].1
5050
with:
5151
# fetch all history so that setuptools-scm works
5252
fetch-depth: 0
@@ -89,7 +89,7 @@ jobs:
8989
9090
# Checkout current GMT repository
9191
- name: Checkout the GMT source from ${{ matrix.gmt_git_ref }} branch
92-
uses: actions/[email protected].0
92+
uses: actions/[email protected].1
9393
with:
9494
repository: 'GenericMappingTools/gmt'
9595
ref: ${{ matrix.gmt_git_ref }}

.github/workflows/ci_tests_legacy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
steps:
4545
# Checkout current git repository
4646
- name: Checkout
47-
uses: actions/[email protected].0
47+
uses: actions/[email protected].1
4848
with:
4949
# fetch all history so that setuptools-scm works
5050
fetch-depth: 0

.github/workflows/dvc-diff.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
steps:
2323
- name: Checkout
24-
uses: actions/[email protected].0
24+
uses: actions/[email protected].1
2525
with:
2626
# fetch all history so that dvc diff works
2727
fetch-depth: 0

.github/workflows/format-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
private-key: ${{ secrets.APP_PRIVATE_KEY }}
1919

2020
# Checkout the pull request branch
21-
- uses: actions/[email protected].0
21+
- uses: actions/[email protected].1
2222
with:
2323
token: ${{ steps.generate-token.outputs.token }}
2424
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}

.github/workflows/publish-to-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout
48-
uses: actions/[email protected].0
48+
uses: actions/[email protected].1
4949
with:
5050
# fetch all history so that setuptools-scm works
5151
fetch-depth: 0

.github/workflows/release-baseline-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Checkout
26-
uses: actions/[email protected].0
26+
uses: actions/[email protected].1
2727

2828
- name: Setup data version control (DVC)
2929
uses: iterative/[email protected]

.github/workflows/style_checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
# Checkout current git repository
2626
- name: Checkout
27-
uses: actions/[email protected].0
27+
uses: actions/[email protected].1
2828

2929
# Setup Python
3030
- name: Set up Python

.github/workflows/type_checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
steps:
3434
# Checkout current git repository
3535
- name: Checkout
36-
uses: actions/[email protected].0
36+
uses: actions/[email protected].1
3737

3838
# Setup Python
3939
- name: Set up Python

doc/install.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ We recommend following the instructions further on to install GMT 6.
8585

8686
## Dependencies
8787

88-
PyGMT requires the following libraries to be installed:
88+
PyGMT requires the following packages to be installed:
8989

9090
- [numpy](https://numpy.org)
9191
- [pandas](https://pandas.pydata.org)
@@ -97,19 +97,10 @@ PyGMT requires the following libraries to be installed:
9797
For the minimum supported versions of the dependencies, please see [](minversions.md).
9898
:::
9999

100-
The following are optional dependencies:
101-
102-
- [IPython](https://ipython.org): For embedding the figures in Jupyter notebooks (recommended).
103-
- [Contextily](https://contextily.readthedocs.io): For retrieving tile maps from the internet.
104-
- [GeoPandas](https://geopandas.org): For using and plotting GeoDataFrame objects.
105-
- [RioXarray](https://corteva.github.io/rioxarray): For saving multi-band rasters to GeoTIFFs.
106-
107100
:::{note}
108-
If you have [PyArrow](https://arrow.apache.org/docs/python/index.html) installed, PyGMT
109-
does have some initial support for `pandas.Series` and `pandas.DataFrame` objects with
110-
Apache Arrow-backed arrays. Specifically, only uint/int/float and date32/date64 dtypes
111-
are supported for now. Support for string Arrow dtypes is still a work in progress.
112-
For more details, see [issue #2800](https://github.com/GenericMappingTools/pygmt/issues/2800).
101+
Some optional dependencies (e.g., [IPython](https://ipython.readthedocs.io/en/stable/),
102+
[GeoPandas](https://geopandas.org/en/stable/)) add more functionality to PyGMT.
103+
For a complete list of the optional dependencies, refer to [](ecosystem.md).
113104
:::
114105

115106
## Installing GMT and other dependencies
@@ -165,6 +156,25 @@ conda activate pygmt
165156
From now on, all commands will take place inside the virtual environment called `pygmt`
166157
and won't affect your default `base` installation.
167158

159+
::::: {tip}
160+
You can also enable more PyGMT functionality by installing PyGMT's optional dependencies in the environment.
161+
:::: {tab-set}
162+
::: {tab-item} mamba
163+
:sync: mamba
164+
```
165+
mamba install contextily geopandas ipython pyarrow rioxarray
166+
```
167+
:::
168+
169+
::: {tab-item} conda
170+
:sync: conda
171+
```
172+
conda install contextily geopandas ipython pyarrow rioxarray
173+
```
174+
:::
175+
::::
176+
:::::
177+
168178
## Installing PyGMT
169179

170180
Now that you have GMT installed and your virtual environment activated, you can install

pygmt/_show_versions.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
"""
2-
Utility methods to print system info for debugging.
2+
Utility methods to print system information for debugging.
33
44
Adapted from :func:`rioxarray.show_versions` and :func:`pandas.show_versions`.
55
"""
66

7-
import importlib
87
import platform
98
import shutil
109
import subprocess
1110
import sys
12-
from importlib.metadata import version
11+
from importlib.metadata import PackageNotFoundError, requires, version
1312
from typing import TextIO
1413

1514
from packaging.requirements import Requirement
@@ -25,25 +24,17 @@ def _get_clib_info() -> dict[str, str]:
2524
"""
2625
Get information about the GMT shared library.
2726
"""
28-
with Session() as ses:
29-
return ses.info
27+
with Session() as lib:
28+
return lib.info
3029

3130

3231
def _get_module_version(modname: str) -> str | None:
3332
"""
3433
Get version information of a Python module.
3534
"""
3635
try:
37-
if modname in sys.modules:
38-
module = sys.modules[modname]
39-
else:
40-
module = importlib.import_module(modname)
41-
42-
try:
43-
return module.__version__
44-
except AttributeError:
45-
return module.version
46-
except ImportError:
36+
return version(modname)
37+
except PackageNotFoundError:
4738
return None
4839

4940

@@ -85,13 +76,12 @@ def _check_ghostscript_version(gs_version: str | None) -> str | None:
8576
f"Ghostscript v{gs_version} has known bugs. "
8677
"Please consider upgrading to version v10.02 or later."
8778
)
88-
case v if v >= Version("10.02"):
89-
if Version(__gmt_version__) < Version("6.5.0"):
90-
return (
91-
f"GMT v{__gmt_version__} doesn't support Ghostscript "
92-
f"v{gs_version}. Please consider upgrading to GMT>=6.5.0 or "
93-
"downgrading to Ghostscript v9.56."
94-
)
79+
case v if v >= Version("10.02") and Version(__gmt_version__) < Version("6.5.0"):
80+
return (
81+
f"GMT v{__gmt_version__} doesn't support Ghostscript v{gs_version}. "
82+
"Please consider upgrading to GMT>=6.5.0 or downgrading to Ghostscript "
83+
"v9.56."
84+
)
9585
return None
9686

9787

@@ -109,22 +99,14 @@ def show_versions(file: TextIO | None = sys.stdout):
10999
It also warns users if the installed Ghostscript version has serious bugs or is
110100
incompatible with the installed GMT version.
111101
"""
112-
113102
sys_info = {
114103
"python": sys.version.replace("\n", " "),
115104
"executable": sys.executable,
116105
"machine": platform.platform(),
117106
}
118-
dep_info = {
119-
Requirement(v).name: _get_module_version(Requirement(v).name)
120-
for v in importlib.metadata.requires("pygmt") # type: ignore[union-attr]
121-
}
122-
dep_info.update(
123-
{
124-
"gdal": _get_module_version("osgeo.gdal"),
125-
"ghostscript": _get_ghostscript_version(),
126-
}
127-
)
107+
requirements = [Requirement(v).name for v in requires("pygmt")] + ["gdal"] # type: ignore[union-attr]
108+
dep_info = {name: _get_module_version(name) for name in requirements}
109+
dep_info.update({"ghostscript": _get_ghostscript_version()})
128110

129111
lines = []
130112
lines.append("PyGMT information:")

0 commit comments

Comments
 (0)