You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(python): update pyproject, docs, and cleanup makefile (#6809)
While working in the python bindings directory I kept hitting some
issues while developing, so I cleaned up a few things that I was able to
figure out.
The main problem was uv sync kept re-resolving the lockfile since our
optional deps had unpinned packages, even if I was just running the
tests. Fixed that by pinning the dev dependencies but ultimately can
revert if im lacking context as to why they weren't pinned before. But
now `uv sync` is stable out the box.
While I was in there I also, did an overhaul of the `MakeFile` so that
install was just one command, leveraged a bit more uv there, and added
help to document everything. Also, updated the docs that referenced the
old logic to use new changes. Although there are a few more places that
need this. i.e. direct `maturin` references.
After this PR:
```
cd python && make install # once
uv run make test # every day
make build # after Rust changes
uv sync # after pulling commits with dep changes
```
---------
Co-authored-by: Xuanwo <github@xuanwo.io>
Copy file name to clipboardExpand all lines: .github/workflows/codex-backport-pr.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ jobs:
142
142
10. Run ONLY the tests related to the changes in these PRs:
143
143
- Use "git diff --name-only ${RELEASE_BRANCH}...HEAD" to see all files changed across all cherry-picked commits.
144
144
- For Rust changes: Run tests for the affected crates only (e.g., "cargo test -p lance-core" if lance-core files changed).
145
-
- For Python changes (python/** files): Build with "cd python && maturin develop" then run "pytest" on the specific test files that were modified, or related test files.
145
+
- For Python changes (python/** files): Build with "cd python && make build" then run "uv run pytest" on the specific test files that were modified, or related test files.
146
146
- For Java changes (java/** files): Run "cd java && mvn test" for the affected modules.
147
147
- If test files themselves were modified, run those specific tests.
148
148
- Do NOT run the full test suite - only run tests related to the changed files.
Copy file name to clipboardExpand all lines: python/AGENTS.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,15 @@ Also see [root AGENTS.md](../AGENTS.md) for cross-language standards.
5
5
## Commands
6
6
7
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.
8
+
* First step in every new worktree or fresh checkout: run `make install` from `python/` before any Python command. This runs `uv sync` (dev and test dependencies are included by default via `[tool.uv] default-groups`) and sets up pre-commit hooks. Add `--group benchmarks`, `--extra torch`, or `--extra geo` only when needed.
9
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
+
* After the initial `make install`, use `uv run make test` to run tests.
11
+
* Only run `uv sync` again when dependencies change (e.g., after pulling new commits that update `pyproject.toml` or `uv.lock`).
10
12
* Command execution: always use `uv run ...` for Python-related repository commands. Do not rely on a globally activated environment.
11
13
* Never invoke bare `python`, `pytest`, `pip`, `maturin`, `make test`, `make doctest`, `make lint`, or `make format` for repository work.
12
14
* 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
+
* Build time expectations: `make install` and `make build` 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.
16
+
* Build: `make build` (required after Rust changes)
15
17
* Test: `uv run make test`
16
18
* Run single test: `uv run pytest python/tests/<test_file>.py::<test_name>`
17
19
* Doctest: `uv run make doctest`
@@ -34,4 +36,4 @@ Also see [root AGENTS.md](../AGENTS.md) for cross-language standards.
34
36
## Common Failure Mode
35
37
36
38
- 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 ...`.
39
+
- Before reporting a Python dependency as unavailable, verify that `uv sync` has been run in the current worktree and that the failing command was executed with `uv run ...`.
Copy file name to clipboardExpand all lines: python/DEVELOPMENT.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,10 @@
3
3
For local development, prefer [uv](https://docs.astral.sh/uv/) to create and manage the Python environment:
4
4
5
5
```shell
6
-
uv sync --extra tests --extra dev
6
+
uv sync
7
7
```
8
8
9
-
Add extras such as `benchmarks`, `torch`, or `geo`only when you need them. After the environment is initialized, either activate it or use `uv run ...` for commands.
9
+
Add `--group benchmarks` for benchmarks, or `--extra torch` / `--extra geo`for those optional features. After the environment is initialized, either activate it or use `uv run ...` for commands.
10
10
11
11
`uv sync` is not just downloading Python packages here. It also builds the local `pylance` Rust extension as part of the editable environment, so the first run, cache misses, or Rust dependency changes can make it noticeably slow. This is expected; let the build finish instead of interrupting it and switching to a different environment setup.
12
12
@@ -17,7 +17,7 @@ This project is built with [maturin](https://github.com/PyO3/maturin).
17
17
It can be built in development mode with:
18
18
19
19
```shell
20
-
uv run maturin develop
20
+
uv run maturin develop --uv
21
21
```
22
22
23
23
This builds the Rust native module in place. You will need to re-run this
@@ -104,8 +104,8 @@ benchmarks added there should run in less than 5 seconds.
104
104
Before running benchmarks, you should build pylance in release mode:
105
105
106
106
```shell
107
-
uv sync --extra tests --extra dev --extra benchmarks
108
-
uv run maturin develop --profile release-with-debug --extras benchmarks --features datagen
0 commit comments