diff --git a/changedetectionio/api/__init__.py b/changedetectionio/api/__init__.py index bc7def13..2a7f7125 100644 --- a/changedetectionio/api/__init__.py +++ b/changedetectionio/api/__init__.py @@ -36,18 +36,11 @@ def get_openapi_spec(): import yaml # Lazy import - only loaded when API validation is actually used from openapi_core import OpenAPI # Lazy import - saves ~10.7 MB on startup - # Try multiple paths to find the API spec file since the package structure differs - # between Docker builds (source tree) and PyPI/pip installations (site-packages) - # 1. Relative path for Docker/development environment where docs/ is in the source tree spec_path = os.path.join(os.path.dirname(__file__), '../../docs/api-spec.yaml') - - # 2. For PyPI/pip installations, use importlib.resources to find the installed file if not os.path.exists(spec_path): - try: - from importlib.resources import files - spec_path = files('changedetectionio').joinpath('../docs/api-spec.yaml') - except Exception: - pass + # Possibly for pip3 packages (will be shipped with the package) + spec_path = os.path.join(os.path.dirname(__file__), '../docs/api-spec.yaml') + # 3. Last resort: check if it's in the package root for pip/PyPI installations if not os.path.exists(spec_path):