()
| 291 | |
| 292 | |
| 293 | def main(): |
| 294 | parser = argparse.ArgumentParser( |
| 295 | description=__doc__, |
| 296 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 297 | ) |
| 298 | parser.add_argument( |
| 299 | "--ref", |
| 300 | default="HEAD^", |
| 301 | help="baseline to compare the working tree against " |
| 302 | "(default: %(default)s; a merge base with master is usually " |
| 303 | "what you want on a branch)", |
| 304 | ) |
| 305 | parser.add_argument( |
| 306 | "--python", |
| 307 | action="append", |
| 308 | metavar="PATH", |
| 309 | help="interpreter whose headers to build against; repeat it to " |
| 310 | "cover a GIL build and a free-threaded one (default: this one)", |
| 311 | ) |
| 312 | parser.add_argument( |
| 313 | "--probe", |
| 314 | metavar="FILE.c", |
| 315 | help="compile this translation unit instead of the extension, to " |
| 316 | "look at an always-inlined helper on its own (see the module " |
| 317 | "docstring)", |
| 318 | ) |
| 319 | parser.add_argument( |
| 320 | "--keep-static", |
| 321 | action="store_true", |
| 322 | help="pass -fkeep-static-functions, which emits a standalone copy " |
| 323 | "of some helpers that are otherwise only visible inlined", |
| 324 | ) |
| 325 | parser.add_argument( |
| 326 | "--self-test", |
| 327 | action="store_true", |
| 328 | help="compile pairs of tiny sources that differ in one known way " |
| 329 | "and check the comparison reports each of them", |
| 330 | ) |
| 331 | parser.add_argument( |
| 332 | "--fail-on-diff", |
| 333 | action="store_true", |
| 334 | help="exit non-zero when any function differs", |
| 335 | ) |
| 336 | args = parser.parse_args() |
| 337 | |
| 338 | if shutil.which("objdump") is None: |
| 339 | sys.exit("objdump not found; install binutils") |
| 340 | |
| 341 | if args.self_test: |
| 342 | return self_test() |
| 343 | |
| 344 | root = Path( |
| 345 | run( |
| 346 | ["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE |
| 347 | ).stdout.strip() |
| 348 | ) |
| 349 | pythons = args.python or [sys.executable] |
| 350 |
no test coverage detected