ukceh-time-stream 4.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+ from typing import TYPE_CHECKING, Any
3
+
4
+ if TYPE_CHECKING:
5
+ # These imports are only for static type checkers (e.g., Pyright, IDEs).
6
+ # At runtime, they are not executed, so the modules won't be imported unless needed.
7
+ from time_stream.base import TimeFrame
8
+
9
+
10
+ try:
11
+ __version__ = version("ukceh-time-stream")
12
+ except PackageNotFoundError:
13
+ __version__ = "unknown"
14
+
15
+ # Declare the public API of the package. This tells `from time_stream import *` what to include.
16
+ __all__ = ["TimeFrame"] # noqa
17
+
18
+
19
+ def __getattr__(name: str) -> Any:
20
+ # NOTE: We use __getattr__ for lazy imports instead of top-level imports because setuptools may evaluate
21
+ # this module during build (e.g., to use the value of time_stream.__version__), before submodules like
22
+ # `time_stream.base` exist. This avoids import-time errors when building from source using pyproject.toml
23
+ # and ensures compatibility with dynamic versioning tools like autosemver.
24
+ #
25
+ # This 'lazy loading' also has additional benefits in that it can help with performance by avoiding unnecessary
26
+ # dependencies being loaded at startup and also gives us control over what to expose from the package.
27
+
28
+ if name == "TimeFrame":
29
+ from time_stream.base import TimeFrame # noqa: PLC0415
30
+
31
+ return TimeFrame
32
+ raise AttributeError(f"module {__name__} has no attribute {name}")