Keeping EXIF data from raw to jpeg in Python, anybody have a good system?

I’m converting raw files to 16-bit tiffs and then after tone-mapping to jpegs. I keep running into issues where the exif data gets too big to save to a jpeg (there’s a 65k limit, who knew?), so I try to keep only the bare essentials (I don’t even know what ExifOffset is and yet it takes up like 65k all by itself sometimes), but then I run into the problem where even though I’m saving with an embedded ICC profile, there is apparently not enough metadata for image viewers to properly decode them and they look garish (in Gwenview and geeqie, but not showFoto which apart from interface problems seems to do color management very well).

Sorry for the long sentence, but if anybody has a process they have perfected, don’t keep it to yourself!