packaging icon indicating copy to clipboard operation
packaging copied to clipboard

feat: support writing metadata

Open henryiii opened this issue 1 year ago • 3 comments

Working toward https://github.com/pypa/packaging/issues/647. Starting by making it possible to go from Metadata back to RFC822.

henryiii avatar Oct 23 '24 08:10 henryiii

I don't know if I'm comfortable with the JSON support. I actually almost had it in the first version of the module, but decided against it until we had a standard around it.

brettcannon avatar Oct 23 '24 21:10 brettcannon

Well, it is in PEP 566, so that's why I added it to pyproject-metadata. Though there's no use for it yet, so I can easily drop it.

I'll probably make a PR building on this PR for the next step.

This is starting as a fairly direct copy of pyproject-metadata, adapted for packaging's existing features and with the non-backward compatible changes listed in https://github.com/pypa/pyproject-metadata/issues/140. I've got permission from the original copyright holders in https://github.com/pypa/pyproject-metadata/issues/103 to contribute to packaging under the packaging license.

This PR also has the following changes vs. the original:

  • All metadata keys are lower case, instead of title case. Headers in messages are not case sensitive.
  • The ordering of the keys is based on the ordering in the Metadata class, which is slightly different compared to pyproject-metadata.

henryiii avatar Oct 24 '24 02:10 henryiii

FYI, on the flaking pypy-3.8 (and 3.9, possibly?) test, PyPy doesn't support pypy-3.8 or pypy-3.9 anymore. Only pypy-3.10 is actively supported.

henryiii avatar Oct 24 '24 05:10 henryiii

Okay, I've compared this to the current implementation in pyproject-metadata. The one fix I've added there is a patch to support form feeds in Python <3.12.4. It's a bit finicky, though, as it only supports form feeds followed by a space (unlike 3.12.4+, which doesn't require that), and since this is a new feature, I think it's fine without the patch unless it turns out to be needed?

henryiii avatar Sep 08 '25 19:09 henryiii