Skip to content

Commit 7c747f6

Browse files
committed
Can't get the cartopy version if it ain't installed!
Found while building conda packages
1 parent 9aa55ca commit 7c747f6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/emsarray/plot.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# required as this module imports optional
2+
# dependencies that are used for type hints.
3+
from __future__ import annotations
4+
15
import importlib.metadata
26
from collections.abc import Callable, Iterable
37
from typing import Any, Literal
@@ -34,7 +38,10 @@
3438

3539
_requires_plot = requires_extra(extra='plot', import_error=IMPORT_EXCEPTION)
3640

37-
CARTOPY_VERSION = packaging.version.Version(importlib.metadata.version('cartopy'))
41+
if CAN_PLOT:
42+
CARTOPY_VERSION = packaging.version.Version(importlib.metadata.version('cartopy'))
43+
else:
44+
CARTOPY_VERSION = packaging.version.Version('0')
3845
CARTOPY_0_23 = CARTOPY_VERSION >= packaging.version.Version('0.23')
3946

4047

0 commit comments

Comments
 (0)