]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Tools/build/stable_abi.py: Improve ergonomics (GH-105355)
authorPetr Viktorin <encukou@gmail.com>
Tue, 17 Sep 2024 12:32:04 +0000 (14:32 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Sep 2024 12:32:04 +0000 (14:32 +0200)
* Tools/build/stable_abi.py: Improve ergonomics

- Make the manifest file argument optional
- Output resolved paths with --list (getting rid of `../../`)
- Mention --all or --generate-all if no actions are specified

* Don't hardcode Misc/stable_abi.toml in Makefile, rely on the default

Makefile.pre.in
Tools/build/stable_abi.py

index de4aed6cb107b6995acfc6eea66dad1938b46ea1..4947680985e8311316684b6b3ebcf74f36e57e7d 100644 (file)
@@ -1696,7 +1696,7 @@ check-abidump: all
 
 .PHONY: regen-limited-abi
 regen-limited-abi: all
-       $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all $(srcdir)/Misc/stable_abi.toml
+       $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --generate-all
 
 ############################################################################
 # Regenerate Unicode Data
@@ -3142,7 +3142,7 @@ patchcheck: all
 
 .PHONY: check-limited-abi
 check-limited-abi: all
-       $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all $(srcdir)/Misc/stable_abi.toml
+       $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/stable_abi.py --all
 
 .PHONY: update-config
 update-config:
index f7fccb636858f0252060f5af7fe64d95a96304ce..2874c436c1ebc9c033dffcd710a1609689fecf79 100644 (file)
@@ -25,6 +25,8 @@ import re
 import csv
 
 SCRIPT_NAME = 'Tools/build/stable_abi.py'
+DEFAULT_MANIFEST_PATH = (
+    Path(__file__).parent / '../../Misc/stable_abi.toml').resolve()
 MISSING = object()
 
 EXCLUDED_HEADERS = {
@@ -641,8 +643,9 @@ def main():
         formatter_class=argparse.RawDescriptionHelpFormatter,
     )
     parser.add_argument(
-        "file", type=Path, metavar='FILE',
-        help="file with the stable abi manifest",
+        "file", type=Path, metavar='FILE', nargs='?',
+        default=DEFAULT_MANIFEST_PATH,
+        help=f"file with the stable abi manifest (default: {DEFAULT_MANIFEST_PATH})",
     )
     parser.add_argument(
         "--generate", action='store_true',
@@ -684,7 +687,7 @@ def main():
 
     if args.list:
         for gen in generators:
-            print(f'{gen.arg_name}: {base_path / gen.default_path}')
+            print(f'{gen.arg_name}: {(base_path / gen.default_path).resolve()}')
         sys.exit(0)
 
     run_all_generators = args.generate_all
@@ -735,8 +738,10 @@ def main():
 
     if not results:
         if args.generate:
-            parser.error('No file specified. Use --help for usage.')
-        parser.error('No check specified. Use --help for usage.')
+            parser.error('No file specified. Use --generate-all to regenerate '
+                         + 'all files, or --help for usage.')
+        parser.error('No check specified. Use --all to check all files, '
+                     + 'or --help for usage.')
 
     failed_results = [name for name, result in results.items() if not result]