After recent discussion around building tooling for fpm, I cleaned up a schema for the Fortran package manifests I had lying around. I tested the schema by validating all ~150 fpm projects which were published on GitHub until October 2021 (I need to update my list).
The schema is defined using a Pydantic model to map the manifest to a Python object. While I like Pydantic for the possibility to quickly create a schema from type hints, the error reporting is somewhat minimalistic. I should note that creating the object from the package manifest is left as exercise for the user:
import tomli as tomllib from pyfpm.model import Manifest with open("fpm.toml", "rb") as fd: package = Manifest(**tomllib.load(fd))
The round-trip is a bit more difficult, since many TOML libraries in Python don’t know how to deal with None values, rather than not printing the value they usually raise an error… meaning you have to prune the dict first from None’s before writing the manifest again.
I also exported the model to JSON schema and uploaded it with the release, in case anyone wants to try it for other tooling other than Python.
Maybe we can use the exported schema once we create our own schema validator in Fortran: