[issue43749] venv module does not copy the correct python exe

Eryk Sun report at bugs.python.org
Fri Dec 10 22:21:25 EST 2021


Eryk Sun <eryksun at gmail.com> added the comment:

The code to copy a file could be rewritten to use a regex match. For example:

            # Copy src to dst. If src is a base executable, copy a launcher.
            dirname, filename = os.path.split(src)
            m = re.match(r'(pythonw?)[0-9._]*((?:_d)?(?:\.exe|\.pdb))$',
                    filename.lower())
            if m is not None:
                src = os.path.join(os.path.dirname(__file__),
                        'scripts', 'nt', m.group(1) + m.group(2))
                # If the base environment is a Python source build, use
                # the launcher in the build directory instead of
                # "Lib/venv/scripts/nt".
                if sysconfig.is_python_build(True) or not os.path.isfile(src):
                    basename = ('venvlauncher' if m.group(1) == 'python' else
                                'venvwlauncher')
                    src = os.path.join(dirname, basename + m.group(2))

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43749>
_______________________________________


More information about the Python-bugs-list mailing list