What is WebComPy

WebComPy is a Python frontend framework for PyScript with the following features.
  • Component-based declarative rendering
  • Automatic DOM refreshing
  • Built-in router
  • CLI tools (Project scaffolding, Dev server, Static Site Generator)
  • Dependency management with lock file sync

Get started with uv (Recommended)

Create a new project and set up dependencies using uv.
mkdir webcompy-project && cd webcompy-project
uv init
uv add webcompy
uv run python -m webcompy init
Add browser dependencies to [project.optional-dependencies] in pyproject.toml:
[project.optional-dependencies]
browser = ["numpy", "matplotlib"]
Configure webcompy_config.py to use auto-discovery, and webcompy_server_config.py with LockfileSyncConfig:
# webcompy_config.py
app_config = AppConfig(
    app_package=Path(__file__).parent / "app",
    base_url="/",
    dependencies=None,
    dependencies_from="browser",
)

# webcompy_server_config.py
lockfile_sync_config = LockfileSyncConfig(sync_group="browser")
Generate the lock file and start the dev server:
uv run python -m webcompy lock
uv run python -m webcompy start --dev

Get started with Poetry

If you prefer Poetry, use the following setup:
mkdir webcompy-project && cd webcompy-project
poetry new webcompy-project && cd webcompy-project
poetry add webcompy
poetry run python -m webcompy init
Add browser dependencies to [project.optional-dependencies] in pyproject.toml (same as the uv setup above).
Then configure webcompy_config.py and webcompy_server_config.py as shown above, and run:
poetry run python -m webcompy lock
poetry run python -m webcompy start --dev
Note: webcompy lock --install uses uv pip or pip, not poetry install. Use webcompy lock --sync to compare versions with pyproject.toml.

Lock File Commands

CommandDescription
webcompy lockGenerate or update the lock file
webcompy lock --exportExport lock file dependencies to requirements.txt
webcompy lock --syncCompare lock file with pyproject.toml / requirements.txt
webcompy lock --installExport and install lock file dependencies

Source Code