"""Makes ``import babytracker_api`` work without Home Assistant. The library is loaded by path because the integration folder holds a calendar.py, which would hide Python's own calendar module if that folder were on sys.path. """ import importlib.util import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent LIBRARY = ROOT / "custom_components" / "babytracker" / "babytracker_api" if "babytracker_api" not in sys.modules: spec = importlib.util.spec_from_file_location( "babytracker_api", LIBRARY / "__init__.py", submodule_search_locations=[str(LIBRARY)] ) module = importlib.util.module_from_spec(spec) sys.modules["babytracker_api"] = module spec.loader.exec_module(module)