Plugin system#
Any third-party package can teach polyxios to read and write a new format - no fork required, no pull request needed.
Step 1 - write a codec#
Two functions, nothing more:
# mypackage/abc_codec.py
from polyxios._registry import Codec
from polyxios._types import PolyData
def read(path, *, lazy=False) -> PolyData:
...
def write(poly: PolyData, path, **opts) -> None:
...
def register():
return ".abc", Codec(read, write)
Step 2 - declare an entry point#
In your pyproject.toml:
[project.entry-points."polyxios.codecs"]
abc = "mypackage.abc_codec:register"
After pip install mypackage, polyxios picks up .abc automatically - no
configuration, no restart needed:
mesh = px.read("model.abc") # works out of the box
Note
Extensions are resolved in lower case, so register ".abc" rather than
".ABC" - a key the resolver cannot reach is worse than none.