Skip to content

Commit 690a7c2

Browse files
authored
docs: tighten python environment workflow guidance (#6520)
This tightens the repository's environment guidance so language-specific tasks must follow the documented workflow before reporting missing tools or dependencies. For Python work, the docs now make `uv sync --extra tests --extra dev` and `uv run ...` mandatory, and explicitly call out the common failure mode where slow `uv sync` is interrupted or global Python is used instead.
1 parent 086833a commit 690a7c2

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ Key technical traits: async-first (tokio), Arrow-native, versioned writes with m
4646

4747
See [python/AGENTS.md](python/AGENTS.md) and [java/AGENTS.md](java/AGENTS.md).
4848

49+
## Language-Specific Environment Contract
50+
51+
- For language-specific tasks, always follow the environment and command rules in the corresponding subdirectory guide before running build, test, lint, format, or tooling commands.
52+
- Do not substitute a different environment manager or toolchain just because a command appears missing, unavailable, or slow.
53+
- If a language-specific command fails outside the documented workflow, treat that as an environment usage mistake first. Fix the environment usage, rerun with the prescribed commands, and only then conclude that a dependency or tool is unavailable.
54+
4955
### Integration Testing
5056

5157
```bash

python/AGENTS.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ Also see [root AGENTS.md](../AGENTS.md) for cross-language standards.
44

55
## Commands
66

7-
* Environment: prefer `uv` for local Python environment setup; start with `uv sync --extra tests --extra dev`, and add other extras such as `benchmarks`, `torch`, or `geo` only when needed.
8-
* Command execution: after initializing the environment with `uv`, either activate the environment or use `uv run ...`; keep `Makefile` targets and CI commands environment-manager agnostic unless CI has been migrated explicitly.
9-
* Build time expectations: `uv sync` and `uv run maturin develop` build the local `pylance` Rust extension as part of the environment workflow. This can be slow, especially on the first run or after Rust dependency changes; treat that as expected and do not switch to a different environment manager just because the build takes time.
10-
* Build: `maturin develop` (required after Rust changes)
11-
* Test: `make test`
12-
* Run single test: `pytest python/tests/<test_file>.py::<test_name>`
13-
* Doctest: `make doctest`
14-
* Lint: `make lint`
15-
* Format: `make format`
7+
* Environment: use `uv` for all local Python environment setup in this repository.
8+
* First step in every new worktree or fresh checkout: run `uv sync --extra tests --extra dev` from `python/` before any Python command. Add other extras such as `benchmarks`, `torch`, or `geo` only when needed.
9+
* `uv sync` builds the local `pylance` Rust extension as part of environment setup. This can take a long time. Start it early, let it finish, and do not interrupt it or switch to a different setup path just because the build is slow.
10+
* Command execution: always use `uv run ...` for Python-related repository commands. Do not rely on a globally activated environment.
11+
* Never invoke bare `python`, `pytest`, `pip`, `maturin`, `make test`, `make doctest`, `make lint`, or `make format` for repository work.
12+
* If a Python command fails outside `uv run`, that does not count as a dependency or test failure. Fix the environment usage first and rerun correctly.
13+
* Build time expectations: `uv sync` and `uv run maturin develop` build the local `pylance` Rust extension as part of the environment workflow. This can be slow, especially on the first run or after Rust dependency changes; treat that as expected and do not switch to a different environment manager or shortcut around the build just because it takes time.
14+
* Build: `uv run maturin develop` (required after Rust changes)
15+
* Test: `uv run make test`
16+
* Run single test: `uv run pytest python/tests/<test_file>.py::<test_name>`
17+
* Doctest: `uv run make doctest`
18+
* Lint: `uv run make lint`
19+
* Format: `uv run make format`
1620

1721
## API Design
1822

@@ -26,3 +30,8 @@ Also see [root AGENTS.md](../AGENTS.md) for cross-language standards.
2630
- Use `@pytest.mark.parametrize` for tests that differ only in inputs — extract shared setup into helpers.
2731
- Add tests to existing `test_{module}.py` files rather than creating new test files for the same module.
2832
- Replace `print()` in tests with `assert` statements.
33+
34+
## Common Failure Mode
35+
36+
- A missing module or missing command error from bare `python`, `pytest`, `pip`, `maturin`, or `make` is usually an environment usage mistake, not a repository issue.
37+
- Before reporting a Python dependency as unavailable, verify that `uv sync --extra tests --extra dev` has been run in the current worktree and that the failing command was executed with `uv run ...`.

0 commit comments

Comments
 (0)