[FIX] حل مشکل ModuleNotFoundError با حذف peikarband.py و استفاده از __init__.py (fix) | ApprovalToken: accepted
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- حذف peikarband.py که با peikarband/ directory تداخل داشت - بهروزرسانی __init__.py برای ایجاد peikarband.peikarband submodule - بهروزرسانی PYTHONPATH در Dockerfile برای پشتیبانی از src.* imports - این تغییرات باعث میشود Reflex بتواند peikarband.peikarband را پیدا کند
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user