In the download_package_pip function you use the pip executable found in the bin directory of sys.prefix to search and download versions & wheels. I'm finding that in certain situations, I cannot guarantee that the pip executable exists (sometimes it is called pip3 instead). I suggest using the pip module, which is always available no matter what the executable is called, and no matter whether you are in a virtual environmetn which is inheriting pip from the base prefix.
In short, replaceing the direct invocation of the pip executable with [sys.executable, '-m', 'pip'] would be a much more robust approach to calling pip, IMO.