Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add check to ensure locked dependencies have source distributions available. #14742

Merged
merged 10 commits into from
Feb 13, 2023
18 changes: 15 additions & 3 deletions scripts-dev/check_locked_deps_have_sdists.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ def main() -> None:
with open(lockfile_path, "rb") as lockfile:
lockfile_content = tomli.load(lockfile)

packages_to_assets: Dict[str, List[Dict[str, str]]] = lockfile_content["metadata"][
"files"
]
packages_to_assets: Dict[str, List[Dict[str, str]]]
# There seem to be two different formats for storing the list of files per package.
if lockfile_content.get("metadata", {}).get("files") is not None:
# either [metadata.files]
packages_to_assets = lockfile_content["metadata"]["files"]
else:
# or a `files` inline table in each [[package]]
packages_to_assets = {
package["name"]: package["files"] for package in lockfile_content["package"]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be part of the poetry 1.3 lockfile format, see python-poetry/poetry#6393

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I'm about to require the new lockfile format in #14860


success = True

Expand All @@ -46,6 +53,11 @@ def main() -> None:
)
sys.exit(1)

print(
f"Poetry lockfile OK. {len(packages_to_assets)} locked packages checked.",
file=sys.stderr,
)


if __name__ == "__main__":
main()