diff --git a/.claude/commands/upgrade-pylib.md b/.claude/commands/upgrade-pylib.md new file mode 100644 index 00000000000..520d5deb7ba --- /dev/null +++ b/.claude/commands/upgrade-pylib.md @@ -0,0 +1,32 @@ +# Upgrade Python Library from CPython + +Upgrade a Python standard library module from CPython to RustPython. + +## Arguments +- `$ARGUMENTS`: Library name to upgrade (e.g., `inspect`, `asyncio`, `json`) + +## Steps + +1. **Delete existing library in Lib/** + - If `Lib/$ARGUMENTS.py` exists, delete it + - If `Lib/$ARGUMENTS/` directory exists, delete it + +2. **Copy from cpython/Lib/** + - If `cpython/Lib/$ARGUMENTS.py` exists, copy it to `Lib/$ARGUMENTS.py` + - If `cpython/Lib/$ARGUMENTS/` directory exists, copy it to `Lib/$ARGUMENTS/` + +3. **Upgrade tests** + - Run: `python lib_updater.py --quick-upgrade cpython/Lib/test/test_$ARGUMENTS` + - This will update the test files with appropriate RustPython markers + +## Example Usage +``` +/upgrade-pylib inspect +/upgrade-pylib json +/upgrade-pylib asyncio +``` + +## Notes +- The cpython/ directory should contain the CPython source that we're syncing from +- lib_updater.py handles adding `# TODO: RUSTPYTHON` markers and `@unittest.expectedFailure` decorators +- After upgrading, you may need to run tests to verify: `cargo run --release -- -m test test_$ARGUMENTS` diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index a2ab43a695c..4667f4ee17b 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -87,11 +87,14 @@ rm -r target/debug/build/rustpython-* && find . | grep -E "\.pyc$" | xargs rm -r # Run Rust unit tests cargo test --workspace --exclude rustpython_wasm -# Run Python snippets tests +# Run Python snippets tests (debug mode recommended for faster compilation) +cargo run -- extra_tests/snippets/builtin_bytes.py + +# Run all Python snippets tests with pytest cd extra_tests pytest -v -# Run the Python test module +# Run the Python test module (release mode recommended for better performance) cargo run --release -- -m test ${TEST_MODULE} cargo run --release -- -m test test_unicode # to test test_unicode.py @@ -99,6 +102,8 @@ cargo run --release -- -m test test_unicode # to test test_unicode.py cargo run --release -- -m test test_unicode -k test_unicode_escape ``` +**Note**: For `extra_tests/snippets` tests, use debug mode (`cargo run`) as compilation is faster. For `unittest` (`-m test`), use release mode (`cargo run --release`) for better runtime performance. + ### Determining What to Implement Run `./whats_left.py` to get a list of unimplemented methods, which is helpful when looking for contribution opportunities. @@ -184,6 +189,12 @@ cargo build --target wasm32-wasip1 --no-default-features --features freeze-stdli cargo run --features jit ``` +### Building venvlauncher (Windows) + +See DEVELOPMENT.md "CPython Version Upgrade Checklist" section. + +**IMPORTANT**: All 4 venvlauncher binaries use the same source code. Do NOT add multiple `[[bin]]` entries to Cargo.toml. Build once and copy with different names. + ## Test Code Modification Rules **CRITICAL: Test code modification restrictions**