Skip to content

Commit d119c47

Browse files
committed
Remake update_lib
1 parent 6f41a94 commit d119c47

File tree

17 files changed

+3231
-582
lines changed

17 files changed

+3231
-582
lines changed

.claude/commands/upgrade-pylib.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ Upgrade a Python standard library module from CPython to RustPython.
55
## Arguments
66
- `$ARGUMENTS`: Library name to upgrade (e.g., `inspect`, `asyncio`, `json`)
77

8+
## Important: Report Tool Issues First
9+
10+
If during the upgrade process you encounter any of the following issues with `scripts/update_lib`:
11+
- A feature that should be automated but isn't supported
12+
- A bug or unexpected behavior in the tool
13+
- Missing functionality that would make the upgrade easier
14+
15+
**STOP the upgrade and report the issue first.** Describe:
16+
1. What you were trying to do
17+
- Library name
18+
- The full command executed (e.g. python scripts/update_lib quick cpython/Lib/$ARGUMENTS.py)
19+
2. What went wrong or what's missing
20+
3. Expected vs actual behavior
21+
22+
This helps improve the tooling for future upgrades.
23+
824
## Steps
925

1026
1. **Delete existing library in Lib/**
@@ -15,18 +31,14 @@ Upgrade a Python standard library module from CPython to RustPython.
1531
- If `cpython/Lib/$ARGUMENTS.py` exists, copy it to `Lib/$ARGUMENTS.py`
1632
- If `cpython/Lib/$ARGUMENTS/` directory exists, copy it to `Lib/$ARGUMENTS/`
1733

18-
3. **Upgrade tests (quick upgrade with lib_updater)**
19-
- If `cpython/Lib/test/test_$ARGUMENTS.py` is a single file:
20-
- Run: `python3 scripts/lib_updater.py --quick-upgrade cpython/Lib/test/test_$ARGUMENTS.py`
21-
- If `cpython/Lib/test/test_$ARGUMENTS/` is a directory:
22-
- Run the script for each `.py` file in the directory:
23-
```bash
24-
for f in cpython/Lib/test/test_$ARGUMENTS/*.py; do
25-
python3 scripts/lib_updater.py --quick-upgrade "$f"
26-
done
27-
```
28-
- This will update the test files with basic RustPython markers (`@unittest.expectedFailure`, `@unittest.skip`, etc.)
29-
- **Handle lib_updater warnings**: If you see warnings like `WARNING: TestCFoo does not exist in remote file`, it means the class structure changed between versions and markers couldn't be transferred automatically. These need to be manually restored in step 4 or added in step 5.
34+
3. **Upgrade tests (quick upgrade with update_lib)**
35+
- Run: `python3 scripts/update_lib quick cpython/Lib/test/test_$ARGUMENTS.py` (single file)
36+
- Or: `python3 scripts/update_lib quick cpython/Lib/test/test_$ARGUMENTS/` (directory)
37+
- This will:
38+
- Patch test files preserving existing RustPython markers
39+
- Run tests and auto-mark new test failures (not regressions)
40+
- Remove `@unittest.expectedFailure` from tests that now pass
41+
- **Handle warnings**: If you see warnings like `WARNING: TestCFoo does not exist in remote file`, it means the class structure changed and markers couldn't be transferred automatically. These need to be manually restored in step 4 or added in step 5.
3042

3143
4. **Review git diff and restore RUSTPYTHON-specific changes**
3244
- Run `git diff Lib/test/test_$ARGUMENTS` to review all changes
@@ -96,10 +108,19 @@ cjson = import_helper.import_fresh_module('json') #, fresh=['_json'])
96108

97109
## Notes
98110
- The cpython/ directory should contain the CPython source that we're syncing from
99-
- `scripts/lib_updater.py` handles basic patching:
111+
- `scripts/update_lib` package handles patching and auto-marking:
112+
- `quick` - Combined patch + auto-mark (recommended)
113+
- `migrate` - Only migrate (patch), no test running
114+
- `auto-mark` - Only run tests and mark failures
115+
- `copy-lib` - Copy library files (not tests)
116+
- The patching:
100117
- Transfers `@unittest.expectedFailure` and `@unittest.skip` decorators with `TODO: RUSTPYTHON` markers
101118
- Adds `import unittest # XXX: RUSTPYTHON` if needed for the decorators
102-
- **Limitation**: If a class was restructured (e.g., method overrides removed), lib_updater will warn and skip those markers
119+
- **Limitation**: If a class was restructured (e.g., method overrides removed), update_lib will warn and skip those markers
120+
- The smart auto-mark:
121+
- Marks NEW test failures automatically (tests that didn't exist before)
122+
- Does NOT mark regressions (existing tests that now fail) - these are warnings
123+
- Removes `@unittest.expectedFailure` from tests that now pass
103124
- The script does NOT preserve all RustPython-specific changes - you must review `git diff` and restore them
104125
- Common RustPython markers to look for:
105126
- `# XXX: RUSTPYTHON` or `# XXX RUSTPYTHON` - Inline comments for code modifications

0 commit comments

Comments
 (0)