Skip to content

Commit 47ea120

Browse files
committed
make it possible to load any additional modules not included in pip install earthkit
1 parent f5257e7 commit 47ea120

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/earthkit/__init__.py

+12-20
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# (C) Copyright 2023- ECMWF.
2-
#
3-
# This software is licensed under the terms of the Apache Licence Version 2.0
4-
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5-
# In applying this licence, ECMWF does not waive the privileges and immunities
6-
# granted to it by virtue of its status as an intergovernmental organisation
7-
# nor does it submit to any jurisdiction.
8-
#
9-
10-
111
try:
122
# NOTE: the `_version.py` file must not be present in the git repository
133
# as it is generated by setuptools at install time
@@ -24,13 +14,15 @@
2414
import earthkit.time as time
2515
import earthkit.transforms as transforms
2616

27-
__all__ = [
28-
"data",
29-
"geo",
30-
"meteo",
31-
"plots",
32-
"regrid",
33-
"time",
34-
"transforms",
35-
"__version__",
36-
]
17+
names = ["data", "geo", "meteo", "plots", "regrid", "time", "transforms"]
18+
19+
20+
import importlib
21+
import pkgutil
22+
23+
for component in pkgutil.iter_modules(__path__, __name__ + "."):
24+
module_name = component.name
25+
module, alias = module_name.split(".")
26+
if alias not in names:
27+
imported_module = importlib.import_module(module_name)
28+
globals()[alias] = imported_module

0 commit comments

Comments
 (0)