Skip to content

Commit 184356b

Browse files
committed
[8.0] Ensure a compatible elastic-transport version is installed
1 parent 47e0824 commit 184356b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

elasticsearch/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,20 @@
2121
import re
2222
import warnings
2323

24+
from elastic_transport import __version__ as _elastic_transport_version
25+
2426
from ._utils import fixup_module_metadata
2527
from ._version import __versionstr__
2628

29+
# Ensure that a compatible version of elastic-transport is installed.
30+
_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore
31+
if _version_groups < (8, 0, 0) or _version_groups > (9, 0, 0):
32+
raise ImportError(
33+
"An incompatible version of elastic-transport is installed. Must be between "
34+
"v8.0.0 and v9.0.0. Install the correct version with the following command: "
35+
"$ python -m pip install 'elastic-transport>=8, <9'"
36+
)
37+
2738
_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore
2839
_major, _minor, _patch = (int(x) for x in _version_groups)
2940
VERSION = __version__ = (_major, _minor, _patch)

0 commit comments

Comments
 (0)