I am going to be quite blunt. I don’t believe in spoon feeding people. Others may assist you with more precise responses if they choose so, but I do not roll that way.
I would spend time reading the source code on github it’s actually really well commented and the answer you seek is in the first few results
If you think that it’s unfair review how I approached a similar problem in the blog: Running Certbot on Windows - Phase 1
My problem was different from yours - i had os.geteuid() issues on windows but the concept is the same. Have a look figure it out and test it
Andrei