(self, env_dir)
return context
Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
Create the directories for the environment.
Create the directories for the environment .
def ensure_directories(self, env_dir):
        """
        Create the directories for the environment.

        Returns a context object which holds paths in the environment,
        for use by subsequent logic.
        """

        def create_if_needed(d):
            if not os.path.exists(d):
                os.makedirs(d)
            elif os.path.islink(d) or os.path.isfile(d):
                raise ValueError('Unable to create directory %r' % d)

        if os.path.exists(env_dir) and self.clear:
            self.clear_directory(env_dir)
        context = types.SimpleNamespace()
        context.env_dir = env_dir
        context.env_name = os.path.split(env_dir)[1]
        prompt = self.prompt if self.prompt is not None else context.env_name
        context.prompt = '(%s) ' % prompt
        create_if_needed(env_dir)
        executable = sys._base_executable
        dirname, exename = os.path.split(os.path.abspath(executable))
        context.executable = executable
        context.python_dir = dirname
        context.python_exe = exename
        if sys.platform == 'win32':
            binname = 'Scripts'
            incpath = 'Include'
            libpath = os.path.join(env_dir, 'Lib', 'site-packages')
        else:
            binname = 'bin'
            incpath = 'include'
            libpath = os.path.join(env_dir, 'lib',
                                   'python%d.%d' % sys.version_info[:2],
                                   'site-packages')
        context.inc_path = path = os.path.join(env_dir, incpath)
        create_if_needed(path)
        create_if_needed(libpath)
        # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
        if ((sys.maxsize > 2**32) and (os.name == 'posix') and
            (sys.platform != 'darwin')):
            link_path = os.path.join(env_dir, 'lib64')
            if not os.path.exists(link_path):   # Issue #21643
                os.symlink('lib', link_path)
        context.bin_path = binpath = os.path.join(env_dir, binname)
        context.bin_name = binname
        context.env_exe = os.path.join(binpath, exename)
        create_if_needed(binpath)
        # Assign and update the command to use when launching the newly created
        # environment, in case it isn't simply the executable script (e.g. bpo-45337)
        context.env_exec_cmd = context.env_exe
        if sys.platform == 'win32':
            # bpo-45337: Fix up env_exec_cmd to account for file system redirections.
            # Some redirects only apply to CreateFile and not CreateProcess
            real_env_exe = os.path.realpath(context.env_exe)
            if os.path.normcase(real_env_exe) != os.path.normcase(context.env_exe):
                logger.warning('Actual environment location may have moved due to '
                               'redirects, links or junctions.\n'
                               '  Requested location: "%s"\n'
                               '  Actual location:    "%s"',
                               context.env_exe, real_env_exe)
                context.env_exec_cmd = real_env_exe
        return context
def ensure_directories ( self , env_dir ) : def create_if_needed ( d ) : if not os . path . exists ( d ) : os . makedirs ( d ) elif os . path . islink ( d ) or os . path . isfile ( d ) : raise ValueError ( 'Unable to create directory %r' % d ) if os . path . exists ( env_dir ) and self . clear : self . clear_directory ( env_dir ) context = types . SimpleNamespace ( ) context . env_dir = env_dir context . env_name = os . path . split ( env_dir ) [ 1 ] prompt = self . prompt if self . prompt is not None else context . env_name context . prompt = '(%s) ' % prompt create_if_needed ( env_dir ) executable = sys . _base_executable dirname , exename = os . path . split ( os . path . abspath ( executable ) ) context . executable = executable context . python_dir = dirname context . python_exe = exename if sys . platform == 'win32' : binname = 'Scripts' incpath = 'Include' libpath = os . path . join ( env_dir , 'Lib' , 'site-packages' ) else : binname = 'bin' incpath = 'include' libpath = os . path . join ( env_dir , 'lib' , 'python%d.%d' % sys . version_info [ : 2 ] , 'site-packages' ) context . inc_path = path = os . path . join ( env_dir , incpath ) create_if_needed ( path ) create_if_needed ( libpath ) # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX if ( ( sys . maxsize > 2 ** 32 ) and ( os . name == 'posix' ) and ( sys . platform != 'darwin' ) ) : link_path = os . path . join ( env_dir , 'lib64' ) if not os . path . exists ( link_path ) : # Issue #21643 os . symlink ( 'lib' , link_path ) context . bin_path = binpath = os . path . join ( env_dir , binname ) context . bin_name = binname context . env_exe = os . path . join ( binpath , exename ) create_if_needed ( binpath ) # Assign and update the command to use when launching the newly created # environment, in case it isn't simply the executable script (e.g. bpo-45337) context . env_exec_cmd = context . env_exe if sys . platform == 'win32' : # bpo-45337: Fix up env_exec_cmd to account for file system redirections. # Some redirects only apply to CreateFile and not CreateProcess real_env_exe = os . path . realpath ( context . env_exe ) if os . path . normcase ( real_env_exe ) != os . path . normcase ( context . env_exe ) : logger . warning ( 'Actual environment location may have moved due to ' 'redirects, links or junctions.\n' '  Requested location: "%s"\n' '  Actual location:    "%s"' , context . env_exe , real_env_exe ) context . env_exec_cmd = real_env_exe return context