Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:4thfever Cultivation world simulator Python Runtime Environment

From Leeroopedia
Knowledge Sources
Domains Backend, Simulation
Last Updated 2026-10-22 16:00 GMT

Overview

Python 3.12+ runtime environment with FastAPI, uvicorn, PyYAML, omegaconf, and websockets for the cultivation world simulation backend.

Description

This environment provides the core Python runtime for the Cultivation World Simulator backend server. It is built on Python 3.12 (Debian Bookworm base in Docker) and includes the FastAPI web framework, uvicorn ASGI server, omegaconf for layered YAML configuration, and websockets for real-time game state synchronization. The runtime reads static configuration from `static/config.yml` and stores user data (settings, secrets, saves) in a platform-specific data directory resolved at runtime.

Usage

Use this environment for running the backend server (`uvicorn src.server.main:app`), executing the simulation engine, running pytest tests, or any development work on the Python backend. It is the mandatory prerequisite for all backend Implementation pages.

System Requirements

Category Requirement Notes
OS Linux, Windows, or macOS Cross-platform; Docker uses Debian Bookworm
Python 3.12+ Dockerfile uses `python:3.12-bookworm`
Hardware CPU-only No GPU required; LLM calls go to remote API
Disk 500MB+ Saves and logs grow with simulation length

Dependencies

System Packages

  • `gcc` / `g++` (for any C-extension compilation)
  • `curl` (health checks in Docker)

Python Packages

  • `PyYAML` >= 6.0
  • `omegaconf` >= 2.3.0
  • `json5` >= 0.9.0
  • `fastapi` >= 0.100.0
  • `uvicorn` >= 0.20.0
  • `websockets` >= 11.0

Testing Dependencies (dev only)

  • `pytest` >= 8.0.0
  • `pytest-asyncio` >= 0.23.0
  • `pytest-cov` >= 4.1.0
  • `httpx` >= 0.27.0
  • `polib` >= 1.2.0
  • `Pillow` >= 11.0.0

Credentials

No environment variables are strictly required for the Python runtime itself. The following are optional for LLM seed configuration:

  • `CWS_DEFAULT_LLM_BASE_URL`: Default LLM API base URL
  • `CWS_DEFAULT_LLM_MODEL`: Default LLM model name
  • `CWS_DEFAULT_LLM_FAST_MODEL`: Fast-mode LLM model name
  • `CWS_DEFAULT_LLM_API_KEY`: LLM API key
  • `CWS_DEFAULT_LLM_MODE`: LLM dispatch mode (default/normal/fast)
  • `CWS_DEFAULT_LLM_MAX_CONCURRENT_REQUESTS`: Max concurrent LLM requests (default 10)
  • `CWS_DEFAULT_LLM_API_FORMAT`: API format ("openai" or "anthropic")

See Environment:4thfever_Cultivation_world_simulator_LLM_Provider_Connectivity for LLM credential details.

Quick Install

# Runtime dependencies only (production)
pip install -r requirements-runtime.txt

# Full dev environment including testing tools
pip install -r requirements.txt

Code Evidence

Python version constraint from `deploy/Dockerfile.backend:2`:

FROM python:3.12-bookworm

Runtime dependencies from `requirements-runtime.txt`:

PyYAML>=6.0
omegaconf>=2.3.0
json5>=0.9.0
fastapi>=0.100.0
uvicorn>=0.20.0
websockets>=11.0

Server startup command from `deploy/Dockerfile.backend:33`:

CMD ["uvicorn", "src.server.main:app", "--host", "0.0.0.0", "--port", "8002"]

Common Errors

Error Message Cause Solution
`ModuleNotFoundError: No module named 'omegaconf'` Runtime deps not installed `pip install -r requirements-runtime.txt`
`ImportError: cannot import name 'get_settings_service'` Incorrect module path or missing src/config package Ensure `pythonpath = "."` in pyproject.toml or run from repo root
`UnicodeDecodeError` on Windows Non-UTF-8 system locale `PYTHONUTF8=1` is set automatically by `encoding_runtime.py`

Compatibility Notes

  • Windows: Supported. `encoding_runtime.py` forces `PYTHONUTF8=1` and `PYTHONIOENCODING=utf-8` to handle CJK characters in non-UTF-8 system locales. Standard streams are patched with `errors="replace"`.
  • macOS: Supported. Data directory uses `~/.local/share/CultivationWorldSimulator-dev/` in dev mode.
  • Linux: Primary deployment target. Data directory uses `$XDG_DATA_HOME` or `~/.local/share/`.
  • Docker: Production deployment uses `python:3.12-bookworm` base with only runtime dependencies (no test deps installed).

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment