Author seliger
Recipients seliger
Date 2017-12-29.02:54:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1514516062.42.0.213398074469.issue32444@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the write-up I posted over on the pyenv issues page:

This is apparently a behavior issue in the way venv works. Not only does this impact 3.6.x, I also confirmed that the same issue occurs with venv in general using the stock 3.5 Python that comes with Ubuntu 16.04.

The trouble is at Lib/venv/__init__.py:111. Starting at line 111:

        if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
            executable = os.environ['__PYVENV_LAUNCHER__']
        else:
            executable = sys.executable
        dirname, exename = os.path.split(os.path.abspath(executable))
        context.executable = executable

This carries down to the setup_python method starting at line 187 (Lib/venv/__init__.py:187). It takes whatever executable that is called as the source, and then creates the others based on a hard coded list (e.g. python and python3).

    def setup_python(self, context):
        """
        Set up a Python executable in the environment.
        :param context: The information for the environment creation request
                        being processed.
        """
        binpath = context.bin_path
        path = context.env_exe
        copier = self.symlink_or_copy
        copier(context.executable, path)
        dirname = context.python_dir
        if os.name != 'nt':
            if not os.path.islink(path):
                os.chmod(path, 0o755)
            for suffix in ('python', 'python3'):
                path = os.path.join(binpath, suffix)
                if not os.path.exists(path):
                    # Issue 18807: make copies if
                    # symlinks are not wanted
                    copier(context.env_exe, path, relative_symlinks_ok=True)
                    if not os.path.islink(path):
                        os.chmod(path, 0o755)
        else:
            subdir = 'DLLs'
            include = self.include_binary
            files = [f for f in os.listdir(dirname) if include(f)]
            for f in files:
                src = os.path.join(dirname, f)
                dst = os.path.join(binpath, f)
                if dst != context.env_exe:  # already done, above
                    copier(src, dst)
            dirname = os.path.join(dirname, subdir)
            if os.path.isdir(dirname):
                files = [f for f in os.listdir(dirname) if include(f)]
                for f in files:
                    src = os.path.join(dirname, f)
                    dst = os.path.join(binpath, f)
                    copier(src, dst)
            # copy init.tcl over
            for root, dirs, files in os.walk(context.python_dir):
                if 'init.tcl' in files:
                    tcldir = os.path.basename(root)
                    tcldir = os.path.join(context.env_dir, 'Lib', tcldir)
                    if not os.path.exists(tcldir):
                        os.makedirs(tcldir)
                    src = os.path.join(root, 'init.tcl')
                    dst = os.path.join(tcldir, 'init.tcl')
                    shutil.copyfile(src, dst)
                    break


If you don't call -m venv as python3.X, you will never get that binary in the bin directory.
History
Date User Action Args
2017-12-29 02:54:22seligersetrecipients: + seliger
2017-12-29 02:54:22seligersetmessageid: <1514516062.42.0.213398074469.issue32444@psf.upfronthosting.co.za>
2017-12-29 02:54:22seligerlinkissue32444 messages
2017-12-29 02:54:20seligercreate