(self, context)
Set up a Python executable in the environment.

        :param context: The information for the environment creation request
                        being processed.
Set up a Python executable in the environment.
Set up a Python executable in the environment .
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
        dirname = context.python_dir
        if os.name != 'nt':
            copier(context.executable, path)
            if not os.path.islink(path):
                os.chmod(path, 0o755)
            for suffix in ('python', 'python3', f'python3.{sys.version_info[1]}'):
                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:
            if self.symlinks:
                # For symlinking, we need a complete copy of the root directory
                # If symlinks fail, you'll get unnecessary copies of files, but
                # we assume that if you've opted into symlinks on Windows then
                # you know what you're doing.
                suffixes = [
                    f for f in os.listdir(dirname) if
                    os.path.normcase(os.path.splitext(f)[1]) in ('.exe', '.dll')
                ]
                if sysconfig.is_python_build(True):
                    suffixes = [
                        f for f in suffixes if
                        os.path.normcase(f).startswith(('python', 'vcruntime'))
                    ]
            else:
                suffixes = ['python.exe', 'python_d.exe', 'pythonw.exe',
                            'pythonw_d.exe']

            for suffix in suffixes:
                src = os.path.join(dirname, suffix)
                if os.path.lexists(src):
                    copier(src, os.path.join(binpath, suffix))

            if sysconfig.is_python_build(True):
                # copy init.tcl
                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
def setup_python ( self , context ) : binpath = context . bin_path path = context . env_exe copier = self . symlink_or_copy dirname = context . python_dir if os . name != 'nt' : copier ( context . executable , path ) if not os . path . islink ( path ) : os . chmod ( path , 0o755 ) for suffix in ( 'python' , 'python3' , f'python3.{sys.version_info[1]}' ) : 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 : if self . symlinks : # For symlinking, we need a complete copy of the root directory # If symlinks fail, you'll get unnecessary copies of files, but # we assume that if you've opted into symlinks on Windows then # you know what you're doing. suffixes = [ f for f in os . listdir ( dirname ) if os . path . normcase ( os . path . splitext ( f ) [ 1 ] ) in ( '.exe' , '.dll' ) ] if sysconfig . is_python_build ( True ) : suffixes = [ f for f in suffixes if os . path . normcase ( f ) . startswith ( ( 'python' , 'vcruntime' ) ) ] else : suffixes = [ 'python.exe' , 'python_d.exe' , 'pythonw.exe' , 'pythonw_d.exe' ] for suffix in suffixes : src = os . path . join ( dirname , suffix ) if os . path . lexists ( src ) : copier ( src , os . path . join ( binpath , suffix ) ) if sysconfig . is_python_build ( True ) : # copy init.tcl 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