We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2dbfd66 commit 6ef7a32Copy full SHA for 6ef7a32
src/confluent_kafka/cimpl/__init__.py
@@ -1,10 +1,18 @@
1
-try:
2
- from .sasl2_3.cimpl import *
3
- variant = "sasl2_3"
4
-except ImportError:
+import importlib
+
+variant = None
5
+for module_name in ("sasl2_3", "sasl2_2", "nodeps"):
6
try:
- from .sasl2_2.cimpl import *
7
- variant = "sasl2_2"
8
- except ImportError:
9
- from .nodeps.cimpl import *
10
- variant = "nodeps"
+ module = importlib.import_module(f".{module_name}.cimpl", __package__)
+ variant = module_name
+ for name in dir(module):
+ if not name.startswith("__"):
11
+ globals()[name] = getattr(module, name)
12
+ break
13
+ except ModuleNotFoundError:
14
+ pass
15
16
+if variant is None:
17
+ msg = "No valid native Python extension found"
18
+ raise ImportError(msg)
0 commit comments