Reid 'arrdem' McKenzie
5b0062468f
This patch teaches Zapp! to introspect the `sources` of a manifest, and look for the well-known `WHEEL` file(s) indicative of an unzipped/installed wheel in the input sources. A wheel can be (somewhat*) correctly reassembled by zipping its unzipped state, so in the presence of unzipped wheels Zapp! will re-zip them and enter them into the manifest appropriately for inclusion. This fixes #6 the nasty way, as there's no good way to make `rules_python` provide wheel dependencies or to translate unrolled wheels back to wheels during rule execution as this would violate Bazel's file dependency model.
38 lines
667 B
Python
38 lines
667 B
Python
"""The Zapp runtime manifest API."""
|
|
|
|
import json
|
|
from copy import deepcopy
|
|
from importlib.resources import open_text
|
|
|
|
|
|
def once(f):
|
|
singleton = object()
|
|
state = singleton
|
|
|
|
def helper(*args, **kwargs):
|
|
nonlocal state
|
|
if state is singleton:
|
|
state = f(*args, **kwargs)
|
|
return state
|
|
|
|
return helper
|
|
|
|
|
|
def copied(f):
|
|
def helper(*args, **kwargs):
|
|
val = f(*args, **kwargs)
|
|
return deepcopy(val)
|
|
|
|
return helper
|
|
|
|
|
|
@copied
|
|
@once
|
|
def manifest():
|
|
"""Return (a copy) of the runtime manifest."""
|
|
|
|
with open_text("zapp", "manifest.json") as fp:
|
|
return json.load(fp)
|
|
|
|
|
|
__all__ = ["manifest"]
|