Package#
- class hugr.package.Package(modules: list[Hugr], extensions: list[Extension] = <factory>)[source]#
Bases:
object
A package of HUGR modules and extensions.
The HUGRs may refer to the included extensions or those not included.
Methods
Deserialize a byte string to a Package object.
Deserialize a JSON string to a Package object.
Deserialize a string to a Package object.
Serialize the package to a HUGR envelope byte string.
Serialize the package to a printable HUGR envelope string.
Export the package as its hugr model representation.
Serialize the package to a HUGR envelope string.
Attributes
HUGR modules in the package.
Extensions included in the package.
- static from_bytes(envelope: bytes) Package [source]#
Deserialize a byte string to a Package object.
Some envelope formats can be read from a string. See
from_str()
.- Parameters:
envelope – The byte string representing a Package.
- Returns:
The deserialized Package object.
- classmethod from_json(json_str: str) Package [source]#
Deserialize a JSON string to a Package object.
- Parameters:
json_str – The JSON string representing a Package.
- Returns:
The deserialized Package object.
- static from_str(envelope: str) Package [source]#
Deserialize a string to a Package object.
Not all envelope formats can be read from a string. See
from_bytes()
for a more general method.- Parameters:
envelope – The string representing a Package.
- Returns:
The deserialized Package object.
- to_bytes(config: EnvelopeConfig | None = None) bytes [source]#
Serialize the package to a HUGR envelope byte string.
Some envelope formats can be encoded into a string. See
to_str()
.
- to_model() Package [source]#
Export the package as its hugr model representation.
At the moment this does not yet contain the extensions.
- to_str(config: EnvelopeConfig | None = None) str [source]#
Serialize the package to a HUGR envelope string.
Not all envelope formats can be encoded into a string. See
to_bytes()
for a more general method.