Validate a PYTHON.json file for problems. Raises an exception if an issue is detected.
(info, extension_modules)
| 622 | |
| 623 | |
| 624 | def validate_python_json(info, extension_modules): |
| 625 | """Validate a PYTHON.json file for problems. |
| 626 | |
| 627 | Raises an exception if an issue is detected. |
| 628 | """ |
| 629 | |
| 630 | if extension_modules: |
| 631 | missing = set(info["build_info"]["extensions"].keys()) - set( |
| 632 | extension_modules.keys() |
| 633 | ) |
| 634 | if missing: |
| 635 | raise Exception( |
| 636 | "extension modules in PYTHON.json lack metadata: %s" |
| 637 | % ", ".join(sorted(missing)) |
| 638 | ) |
| 639 | |
| 640 | for name, variants in sorted(info["build_info"]["extensions"].items()): |
| 641 | for ext in variants: |
| 642 | local_links = set() |
| 643 | |
| 644 | for link in ext["links"]: |
| 645 | if "path_static" in link: |
| 646 | local_links.add(link["path_static"]) |
| 647 | if "path_dynamic" in link: |
| 648 | local_links.add(link["path_dynamic"]) |
| 649 | |
| 650 | if not local_links and "framework" not in link and "system" not in link: |
| 651 | raise Exception( |
| 652 | f"Invalid link entry for extension {name}: link type not defined" |
| 653 | ) |
| 654 | |
| 655 | if ( |
| 656 | local_links |
| 657 | and not ext.get("licenses") |
| 658 | and not ext.get("license_public_domain") |
| 659 | ): |
| 660 | raise Exception( |
| 661 | "Missing license annotations for extension %s for library files %s" |
| 662 | % (name, ", ".join(sorted(local_links))) |
| 663 | ) |
no outgoing calls
no test coverage detected