diff --git a/zapp/compiler/__main__.py b/zapp/compiler/__main__.py index b1596b2..72f4f7f 100644 --- a/zapp/compiler/__main__.py +++ b/zapp/compiler/__main__.py @@ -196,6 +196,8 @@ def rezip_wheels(opts, manifest): if s["source"].endswith("/WHEEL") ] + manifest["requirements"] = {} + # Zip up the wheels and insert wheel records to the manifest for w in wheels: # 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 manifest["wheels"][wn] = {"hashes": [], "source": wf} + # Insert the requirement + manifest["requirements"][w["meta"]["Name"]] = w["meta"]["Version"] + return manifest diff --git a/zapp/support/manifest.py b/zapp/support/manifest.py index e3bd590..b26d08a 100644 --- a/zapp/support/manifest.py +++ b/zapp/support/manifest.py @@ -1,5 +1,6 @@ """The Zapp runtime manifest API.""" +import argparse import json from copy import deepcopy from importlib.resources import open_text @@ -35,4 +36,20 @@ def manifest(): 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"]