diff --git a/docker/Dockerfile b/docker/Dockerfile index 6344033..da48eac 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,8 +50,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # This ensures peikarband.peikarband module can be found by Reflex COPY peikarband/ /build/peikarband/ -# Set PYTHONPATH to include /build so Reflex can find the peikarband package -ENV PYTHONPATH=/build +# Set PYTHONPATH to include /build (for peikarband package) and /build/peikarband (for src imports) +# This allows both peikarband.peikarband and src.* imports to work +ENV PYTHONPATH=/build:/build/peikarband # Initialize Reflex and build frontend from peikarband directory # Reflex needs to run from the directory containing rxconfig.py @@ -137,10 +138,11 @@ RUN chmod -R 755 /app && \ # Environment variables # PYTHONPATH=/app allows importing peikarband.peikarband +# PYTHONPATH also includes /app/peikarband for src.* imports # REFLEX_DIR points to the directory containing rxconfig.py ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ - PYTHONPATH=/app \ + PYTHONPATH=/app:/app/peikarband \ PATH="/app/.venv/bin:$PATH" \ REFLEX_DIR=/app/peikarband \ NODE_ENV=production diff --git a/peikarband/__init__.py b/peikarband/__init__.py index c4e9329..a04cc89 100644 --- a/peikarband/__init__.py +++ b/peikarband/__init__.py @@ -1,9 +1,26 @@ """Peikarband Landing Application Package. -This package makes peikarband a proper Python package. -The actual app is exported from peikarband.peikarband module. +This package exports the Reflex app instance. +Reflex expects to find 'app' in peikarband.peikarband when app_name='peikarband'. +We create a peikarband submodule to satisfy this requirement. """ -# Empty init - the app is in peikarband.py submodule -__all__ = [] +# Import app from app.py module (same package) +from .app import app + +# Create peikarband submodule to satisfy Reflex's peikarband.peikarband lookup +import sys +from types import ModuleType + +# Create a peikarband submodule that contains the app +# This allows Reflex to find peikarband.peikarband.app +_peikarband_module = ModuleType('peikarband.peikarband') +_peikarband_module.app = app +_peikarband_module.__all__ = ['app'] +sys.modules['peikarband.peikarband'] = _peikarband_module + +# Also make peikarband attribute available for direct access +peikarband = _peikarband_module + +__all__ = ["app", "peikarband"]