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 initAdd 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 --devGet started with Poetry
If you prefer Poetry, use the following setup:
Then configure
mkdir webcompy-project && cd webcompy-project
poetry new webcompy-project && cd webcompy-project
poetry add webcompy
poetry run python -m webcompy initAdd 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 --devNote: webcompy lock --install uses uv pip or pip, not poetry install. Use webcompy lock --sync to compare versions with pyproject.toml.Lock File Commands
| Command | Description |
|---|---|
webcompy lock | Generate or update the lock file |
webcompy lock --export | Export lock file dependencies to requirements.txt |
webcompy lock --sync | Compare lock file with pyproject.toml / requirements.txt |
webcompy lock --install | Export and install lock file dependencies |