-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy path__main__.py
More file actions
104 lines (79 loc) · 2.79 KB
/
__main__.py
File metadata and controls
104 lines (79 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
"""
Update library tools for RustPython.
Usage:
python scripts/update_lib quick cpython/Lib/test/test_foo.py
python scripts/update_lib copy-lib cpython/Lib/dataclasses.py
python scripts/update_lib migrate cpython/Lib/test/test_foo.py
python scripts/update_lib patches --from Lib/test/foo.py --to cpython/Lib/test/foo.py
python scripts/update_lib auto-mark Lib/test/test_foo.py
"""
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description="Update library tools for RustPython",
)
subparsers = parser.add_subparsers(dest="command", required=True)
subparsers.add_parser(
"quick",
help="Quick update: patch + auto-mark (recommended)",
add_help=False,
)
subparsers.add_parser(
"migrate",
help="Migrate test file(s) from CPython, preserving RustPython markers",
add_help=False,
)
subparsers.add_parser(
"patches",
help="Patch management (extract/apply patches between files)",
add_help=False,
)
subparsers.add_parser(
"auto-mark",
help="Run tests and auto-mark failures with @expectedFailure",
add_help=False,
)
subparsers.add_parser(
"copy-lib",
help="Copy library file/directory from CPython (delete existing first)",
add_help=False,
)
subparsers.add_parser(
"deps",
help="Show dependency information for a module",
add_help=False,
)
subparsers.add_parser(
"todo",
help="Show prioritized list of modules to update",
add_help=False,
)
args, remaining = parser.parse_known_args(argv)
if args.command == "quick":
from update_lib.cmd_quick import main as quick_main
return quick_main(remaining)
if args.command == "copy-lib":
from update_lib.cmd_copy_lib import main as copy_lib_main
return copy_lib_main(remaining)
if args.command == "migrate":
from update_lib.cmd_migrate import main as migrate_main
return migrate_main(remaining)
if args.command == "patches":
from update_lib.cmd_patches import main as patches_main
return patches_main(remaining)
if args.command == "auto-mark":
from update_lib.cmd_auto_mark import main as cmd_auto_mark_main
return cmd_auto_mark_main(remaining)
if args.command == "deps":
from update_lib.cmd_deps import main as cmd_deps_main
return cmd_deps_main(remaining)
if args.command == "todo":
from update_lib.cmd_todo import main as cmd_todo_main
return cmd_todo_main(remaining)
return 0
if __name__ == "__main__":
sys.exit(main())