Working and well-packaged python implementation based on dhall-rust


#1

Hey folks,

I’d like to announce that I’ve been working on python bindings to dhall-rust, which can be found here: https://github.com/s-zeng/dhall-python

As far as I have seen, I have the only python binding to have the following:

  • Support for both load(s) and dump(s), as well as comprehensive language feature support (thanks to dhall-rust)
  • Easy installation: just pip install dhall-python and go. Supports Mac OS, Windows, and Linux, on python versions 3.6 through 3.9
  • Union erasure

Shoutouts to @lisael, SupraSummus, and @tristanC for prior work/alternative bindings in this area.

Motivation:

  1. I wanted to write to dhall files from python and no other solution offered that as of time of writing
  2. Having union erasure means that I can dhall.loads on lists of dhall-kubernetes Record values and have it successfully imported into python
  3. My team at my company only wants well-packaged and polished python libraries - we don’t want to have to git clone and build, and we need to run this code on multiple python versions on multiple operating systems

I’d like to thank @tristanC for the foundation, as this is forked off of his work. I simply took what he did with hyperjson and threw in a bunch of dev-ops work + update to serde_dhall 0.8.0 for dump(s) + better serde value handling.

Future work would probably consist of:

  • .pyi type stubs
  • Flags for things like union erasure, omitting nulls, etc.
  • Representative python types that we can use to serialize into Dhall Optional/union types. We can probably use these for de-serializing too
  • Remove ability to/make it hard to dump mal-typed dhall
  • Fix a small handful of corner case bugs

Let me know what you all think


#2

That is great to hear, I did not pursuit that binding (and learnt haskell instead :-). I’ve invited you as the owner for https://pypi.org/project/dhall/ if you want the namespace, feel free to remove me from the admins.


#3

I also have a PR up to mention the Python bindings on docs.dhall-lang.org: