Parse out version info and insert it to the manifest

This commit is contained in:
Reid 'arrdem' McKenzie 2022-11-21 01:22:56 -07:00
parent 71f5230f9e
commit 9f84e9f84a
2 changed files with 22 additions and 0 deletions

View file

@ -196,6 +196,8 @@ def rezip_wheels(opts, manifest):
if s["source"].endswith("/WHEEL") if s["source"].endswith("/WHEEL")
] ]
manifest["requirements"] = {}
# Zip up the wheels and insert wheel records to the manifest # Zip up the wheels and insert wheel records to the manifest
for w in wheels: for w in wheels:
# Try to cheat and hit in the local cache first rather than building wheels every time # Try to cheat and hit in the local cache first rather than building wheels every time
@ -223,6 +225,9 @@ def rezip_wheels(opts, manifest):
# Insert a new wheel source # Insert a new wheel source
manifest["wheels"][wn] = {"hashes": [], "source": wf} manifest["wheels"][wn] = {"hashes": [], "source": wf}
# Insert the requirement
manifest["requirements"][w["meta"]["Name"]] = w["meta"]["Version"]
return manifest return manifest

View file

@ -1,5 +1,6 @@
"""The Zapp runtime manifest API.""" """The Zapp runtime manifest API."""
import argparse
import json import json
from copy import deepcopy from copy import deepcopy
from importlib.resources import open_text from importlib.resources import open_text
@ -35,4 +36,20 @@ def manifest():
return json.load(fp) return json.load(fp)
PARSER = argparse.ArgumentParser()
PARSER.add_argument("--json", action="store_const", const="json", dest="format", default="json")
PARSER.add_argument("--requirements", action="store_const", const="requirements", dest="format")
if __name__ == "__main__":
opts, args = PARSER.parse_known_args()
if opts.format == "json":
print(json.dumps(manifest()))
elif opts.format == "requirements":
for req, rev in manifest()["requirements"].items():
print("{}=={}".format(req, rev))
__all__ = ["manifest"] __all__ = ["manifest"]