From 066ce4a5c1f1bebee2e35fdd9a24dd7ce6064fda Mon Sep 17 00:00:00 2001 From: "Ehsan.Asadi" Date: Wed, 31 Dec 2025 04:12:32 +0330 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D8=AD=D9=84=20=D9=85=D8=B4=DA=A9=D9=84?= =?UTF-8?q?=20ModuleNotFoundError=20=D8=A8=D8=A7=20=D8=AD=D8=B0=D9=81=20pe?= =?UTF-8?q?ikarband.py=20=D9=88=20=D8=A7=D8=B3=D8=AA=D9=81=D8=A7=D8=AF?= =?UTF-8?q?=D9=87=20=D8=A7=D8=B2=20=5F=5Finit=5F=5F.py=20(fix)=20|=20Appro?= =?UTF-8?q?valToken:=20accepted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - حذف peikarband.py که با peikarband/ directory تداخل داشت - به‌روزرسانی __init__.py برای ایجاد peikarband.peikarband submodule - به‌روزرسانی PYTHONPATH در Dockerfile برای پشتیبانی از src.* imports - این تغییرات باعث می‌شود Reflex بتواند peikarband.peikarband را پیدا کند --- docker/Dockerfile | 8 +++++--- peikarband/__init__.py | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) 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"]