diff --git a/AGENTS.md b/AGENTS.md index cfe3d3746..79e4de58b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,11 +20,21 @@ Common commands: * Format Rust: `cargo fmt --all` * Format Python: `ruff format .` * Lint Python: `ruff check .` +* Bootstrap Python dev env: `cd python && uv run --extra tests --extra dev maturin develop --extras tests,dev` +* Run Python tests: `cd python && uv run --extra tests pytest python/tests -vv --durations=10 -m "not slow and not s3_test"` +* Run specific Python test: `cd python && uv run --extra tests pytest python/tests/.py:: -q` + +For Python validation, prefer the uv-managed environment declared by `python/uv.lock`. +Do not treat system `python`, global `pytest`, or missing editable-install errors as +final blockers; bootstrap or enter the uv environment instead. If `lancedb._lancedb` +is missing or stale, or if Rust/PyO3 binding code changed, rebuild the Python +extension with the bootstrap command above before running tests. Before committing changes, run formatting for every language you touched. At minimum: * Rust changes: run `cargo fmt --all`. -* Python changes: run `ruff format .` and `ruff check .` from the repository root. +* Python changes: run `ruff format .` and `ruff check .` from the repository root, + and run targeted tests through `cd python && uv run ...`. * TypeScript changes: run the relevant `npm`/`pnpm` lint, format, build, and docs commands in `nodejs`. Before creating a PR, make sure the PR title follows Conventional Commits, such as diff --git a/python/AGENTS.md b/python/AGENTS.md index 993e83cf9..b263ff5f8 100644 --- a/python/AGENTS.md +++ b/python/AGENTS.md @@ -4,16 +4,26 @@ code is in the `src/` directory and the Python bindings are in the `lancedb/` di Common commands: +* Bootstrap dev env: `uv run --extra tests --extra dev maturin develop --extras tests,dev` * Build: `make develop` * Format: `make format` * Lint: `make check` * Fix lints: `make fix` -* Test: `make test` -* Doc test: `make doctest` +* Test: `uv run --extra tests pytest python/tests -vv --durations=10 -m "not slow and not s3_test"` +* Run specific test: `uv run --extra tests pytest python/tests/.py:: -q` +* Doc test: `uv run --extra tests pytest --doctest-modules python/lancedb` + +Use the uv-managed environment declared by `uv.lock` for Python validation. Do +not treat system `python`, global `pytest`, or missing editable-install errors +as final blockers; bootstrap or enter the uv environment instead. `make test` +and `make doctest` assume the development environment is already prepared. Before committing changes, run lints and then formatting. -When you change the Rust code, you will need to recompile the Python bindings: `make develop`. +When you change the Rust code, PyO3 binding code, or see a missing/stale +`lancedb._lancedb`, recompile the Python bindings with +`uv run --extra tests --extra dev maturin develop --extras tests,dev` before +running tests. When you export new types from Rust to Python, you must manually update `python/lancedb/_lancedb.pyi` with the corresponding type hints. You can run `pyright` to check for type errors in the Python code.