FROM python:3.11-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ && rm -rf /var/lib/apt/lists/* # ── 1) Vedic (印度占星) 计算栈 — 按 CNWU16 setup_env.py 顺序 ── # dashaflow 声明依赖已停更的 pyswisseph,必须 --no-deps 跳过 # PyJHora 隐藏依赖 (numpy/geocoder/geopy/requests/timezonefinder/python-dateutil) 需显式装 RUN pip install --no-cache-dir \ "pysweph>=2.10.3.5" "pytz>=2024.1" numpy geocoder geopy requests timezonefinder python-dateutil \ && pip install --no-cache-dir --no-deps "dashaflow>=0.3" \ && pip install --no-cache-dir "PyJHora==4.8.6" # ── 2) 西方盘栈 (kerykeion 等) — 后装 ── # kerykeion 的 pyswisseph 会覆盖 swisseph C 模块;Task 0 已验证两引擎仍都正常 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # ── 3) 修复 pytz (kerykeion 依赖链会把 pytz 降级,dashaflow 要 >=2024.1) ── RUN pip install --no-cache-dir "pytz>=2024.1" # Copy application code COPY app.py calculation_lock.py ./ COPY vedic/ ./vedic/ # 2026-07-12 Phase 3: 四层schema(meta/strength/timing/evidence) — 漏COPY会导致 # HF Space构建后 `from evidence import ...` ImportError,务必跟app.py一起加 COPY evidence.py . # ── 4) 下载 PyJHora 必需的 .se1 星历 (HF 不接受 binary 入 git;PyJHora SAV 硬依赖 .se1,Moshier 不兜底) # 源: Swiss Ephemeris 官方 GitHub 镜像 (aloistr/swisseph) RUN python -c "import jhora, os, urllib.request; \ d = os.path.join(os.path.dirname(jhora.__file__), 'data', 'ephe'); \ os.makedirs(d, exist_ok=True); \ base = 'https://raw.githubusercontent.com/aloistr/swisseph/master/ephe'; \ [urllib.request.urlretrieve(base + '/' + n, os.path.join(d, n)) for n in ['seas_18.se1','semo_18.se1','sepl_18.se1']]; \ print('ephe .se1 downloaded from GitHub to', d)" # Expose port 7860 (required by Hugging Face Spaces) EXPOSE 7860 # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]