mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-05-03 08:10:37 +00:00
simpler
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user