This looks pretty good to me. The refactoring of the non-Windows parts makes sense. The Windows parts look reasonable on manual inspection, but again, I don't have access to Windows here, so someone else should also look it over.
I was going to say that at least it is getting tested on the CI, but I have found out that meson changes version(). That is fixed in this version.
Now is currently failing due to [1], so maybe we can leave this patch on hold until that's addressed.