Coding 2022-08-29

By Max Woerner Chase

The package tests are improved, and I'm trying to get the Build tests working. It's slow going, because the pyproject-build command is failing. After I wired stuff up enough that I could actually see the errors, I'm pretty sure they're indicating that there's something wrong with the synthetic packages I'm having it build, but...

Wait. It's trying to find the package name instead of the module name.


Ugh, TOML, why?

Well, in any case, I shouldn't have too much trouble testing the error case.


You should explain.



You should explain what was going wrong. After all, everything was spec-conformant except for your code.

Ugh, fine.

So, here's the code that was broken:

    # ...
    "tool.flit.module": {"name": module_name},

And here's what worked:

    # ...
    "tool": {"flit": {"module": {"name": module_name}}},

That dict is an argument to the tomli_w.dumps function. As I saw it, I had two basic options for how to generate the synthetic pyproject.toml file. Either I could substitute into a template, or I could generate the data corresponding to the contents of the file, and convert it to a string. I decided to manipulate the data, because I figured that would be less of a pain than setting up templating or a big format string. I'm... not sure that was the case, but at least now I've cleared what's hopefully the biggest hurdle to that.

See, the difference between those two snippets is, one works, and the other doesn't, and the one that works, works because it's writing data that corresponds to this block from the examples in Flit's documentation:

name = "nsist"

In TOML, this corresponds to a table containing a key called "name", and that table is described by one of the above snippets. See, TOML has a bunch of syntactic sugar, and those dots in the file don't correspond to the dots in the first snippet. They correspond to the table nesting in the second snippet.

So, before I fixed this, I was writing the table I needed to write, to some weird gibberish key in the top level, rather than the nice telescoping whatever that's going on there.

I'd read this in the documentation back when TOML was taking off, but I didn't think through the implications this had for generating TOML from data rather than from text.

So, there it is, one of the hurdles I had to clear was that I wasn't thinking hard enough about the format that my data was in. Happy?




Anyway, I let this go late and I need to get to bed now.

Good night.