|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is `webview_python`, a Python library providing bindings for the webview library to create desktop applications with web technologies. The project follows the deno_webview design principles and supports cross-platform development (Windows, macOS, Linux). |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +```bash |
| 13 | +# Run all tests |
| 14 | +python -m unittest discover tests |
| 15 | +# or |
| 16 | +pytest |
| 17 | + |
| 18 | +# Run tests with coverage |
| 19 | +pytest --cov |
| 20 | +``` |
| 21 | + |
| 22 | +### Building |
| 23 | +```bash |
| 24 | +# Install build dependencies |
| 25 | +pip install -r requirements.txt |
| 26 | + |
| 27 | +# Build wheel packages |
| 28 | +python -m build -n -w |
| 29 | + |
| 30 | +# Build source distribution |
| 31 | +python -m build -n -s |
| 32 | +``` |
| 33 | + |
| 34 | +### Development Setup |
| 35 | +```bash |
| 36 | +# Install development dependencies |
| 37 | +pip install -r requirements.txt |
| 38 | + |
| 39 | +# Install package in development mode |
| 40 | +pip install -e . |
| 41 | +``` |
| 42 | + |
| 43 | +## Project Architecture |
| 44 | + |
| 45 | +### Core Structure |
| 46 | +- `src/webview/webview.py` - Main Webview class and API implementation |
| 47 | +- `src/webview/_webview_ffi.py` - Foreign Function Interface for native webview library |
| 48 | +- `src/webview/__init__.py` - Package initialization |
| 49 | + |
| 50 | +### Key Components |
| 51 | + |
| 52 | +**Webview Class**: Main interface providing: |
| 53 | +- Window creation and management |
| 54 | +- JavaScript-Python bidirectional binding |
| 55 | +- Async function support for long-running operations |
| 56 | +- Window sizing, title, and navigation control |
| 57 | + |
| 58 | +**FFI Layer**: Handles native library loading and C API bindings, with automatic platform detection and library downloading from GitHub releases or custom locations. |
| 59 | + |
| 60 | +**Async Support**: Built-in support for async Python functions callable from JavaScript, enabling non-blocking operations and progress reporting. |
| 61 | + |
| 62 | +### Environment Variables |
| 63 | +- `WEBVIEW_VERSION`: Specify webview library version (default: "0.9.0") |
| 64 | +- `WEBVIEW_DOWNLOAD_BASE`: Custom download location for webview libraries |
| 65 | + |
| 66 | +### Examples Structure |
| 67 | +- `examples/` - Comprehensive examples including basic usage, async operations, and framework integrations |
| 68 | +- `examples/async_with_asyncio_guest_run/` - Advanced async examples with asyncio integration |
| 69 | + |
| 70 | +## Testing Architecture |
| 71 | + |
| 72 | +Tests are located in `tests/` directory: |
| 73 | +- `test_webview.py` - Core webview functionality tests |
| 74 | +- `test_library.py` - Library loading and FFI tests |
| 75 | + |
| 76 | +## Release Process |
| 77 | + |
| 78 | +Version management through `pyproject.toml`. GitHub Actions handles automated testing and PyPI publishing on tag creation. Manual release steps documented in README.md. |
0 commit comments