Skip to content

Commit 5deab88

Browse files
committed
check matching versions for arviz-xyz
1 parent cfd629b commit 5deab88

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ classifiers = [
2525
]
2626
dynamic = ["version", "description"]
2727
dependencies = [
28-
"arviz_base>=0.7.0",
29-
"arviz_stats[xarray]>=0.7.0",
30-
"arviz_plots>=0.7.0",
28+
"arviz_base >=0.7.0",
29+
"arviz_stats[xarray] >=0.7.0",
30+
"arviz_plots >=0.7.0",
3131
]
3232

3333
[tool.flit.module]

src/arviz/__init__.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Expose features from _ArviZverse_ refactored packages together in the ``arviz`` namespace."""
33

44
import logging
5+
import re
56

67
_log = logging.getLogger(__name__)
78

@@ -16,12 +17,8 @@
1617
"exposing its functions as part of the `arviz` namespace"
1718
)
1819
_log.info(_status)
19-
except ModuleNotFoundError:
20-
_status = "arviz_base not installed"
21-
_log.exception(_status)
22-
except ImportError:
23-
_status = "Unable to import arviz_base"
24-
_log.exception(_status)
20+
except ModuleNotFoundError as err:
21+
raise ImportError("arviz's dependency arviz_base is not installed", name="arviz") from err
2522

2623
info += _status + "\n"
2724

@@ -33,17 +30,15 @@
3330
import arviz_base as base
3431
import arviz_stats as stats
3532

33+
# TODO: remove patch. 0.7 version of arviz-stats didn't expose the __version__ attribute
3634
_status = (
37-
f"arviz_stats {getattr(stats, '__version__', '0.0')} available, "
35+
f"arviz_stats {getattr(stats, '__version__', '0.7.0')} available, "
3836
"exposing its functions as part of the `arviz` namespace"
3937
)
4038
_log.info(_status)
41-
except ModuleNotFoundError:
42-
_status = "arviz_stats not installed"
43-
_log.exception(_status)
44-
except ImportError:
45-
_status = "Unable to import arviz_stats"
46-
_log.exception(_status)
39+
except ModuleNotFoundError as err:
40+
raise ImportError("arviz's dependency arviz_stats is not installed", name="arviz") from err
41+
4742
info += _status + "\n"
4843

4944
try:
@@ -55,12 +50,8 @@
5550
"exposing its functions as part of the `arviz` namespace"
5651
)
5752
_log.info(_status)
58-
except ModuleNotFoundError:
59-
_status = "arviz_plots not installed"
60-
_log.exception(_status)
61-
except ImportError:
62-
_status = "Unable to import arviz_plots"
63-
_log.exception(_status)
53+
except ModuleNotFoundError as err:
54+
raise ImportError("arviz's dependency arviz_plots is not installed", name="arviz") from err
6455

6556
info += _status
6657

@@ -69,5 +60,13 @@
6960

7061
info = f"Status information for ArviZ {__version__}\n\n{info}"
7162

63+
pat = re.compile(r"arviz_(base|stats|plots)\s([0-9]+\.[0-9]+)")
64+
matches = pat.findall(info)
65+
if any(matches[0][1] != match[1] for match in matches[1:]):
66+
raise ImportError(
67+
"Versions of arviz-xyz packages don't match to the minor version. "
68+
f"The versions found are: {matches}"
69+
)
70+
7271
# clean namespace
73-
del logging, _status
72+
del logging, matches, pat, re, _status

0 commit comments

Comments
 (0)