parameters: (base_dir)
docstring: Creates a new virtual python environment in base_dir, sets convenient
    defaults for it, and installs the external modules we need.
    Currently those modules are:
      - numpy.
      - matplotlib.
  
    Raises a VirtualEnvCreationError on failure.
docstring_summary: Creates a new virtual python environment in base_dir, sets convenient
    defaults for it, and installs the external modules we need.
    Currently those modules are:
      - numpy.
      - matplotlib.
docstring_tokens: Creates a new virtual python environment in base_dir sets convenient defaults for it and installs the external modules we need . Currently those modules are : - numpy . - matplotlib .
function: def _CreateVirtualEnv(base_dir):
    """Creates a new virtual python environment in base_dir, sets convenient
    defaults for it, and installs the external modules we need.
    Currently those modules are:
      - numpy.
      - matplotlib.
  
    Raises a VirtualEnvCreationError on failure.
    """
    # We want all paths to be absolute.
    base_dir = os.path.abspath(base_dir)
  
    if os.path.exists(base_dir):
      command = ['cmd', '/c', 'rmdir', '/s', '/q', base_dir]
      _Subprocess(command, 'Failed to delete existing directory')
  
    # Start by creating the output directory and copying python26.dll, as well
    # as pywintypes26.dll into it, as if the DLLs are not in path, the virtual
    # environment won't work.
    script_dir = os.path.join(base_dir, 'Scripts')
    try:
      os.makedirs(script_dir)
      dll_path = os.path.join(os.path.dirname(sys.executable), 'python26.dll')
      shutil.copy(dll_path, script_dir)
  
      dll_path = os.path.join(os.path.dirname(sys.executable), 'pywintypes26.dll')
      shutil.copy(dll_path, script_dir)
  
      dll_path = os.path.join(os.path.dirname(sys.executable), 'pythoncom26.dll')
      shutil.copy(dll_path, script_dir)
    except Exception:
      _LOGGER.exception('Unable to copy python DLL')
      raise VirtualEnvCreationError('Unable to copy python DLL')
  
    # Run virtualenv.py with our selfsame python interpreter.
    command = [sys.executable,
               os.path.join(_VIRTUALENV_DIR, 'virtualenv.py'),
               '--verbose',
               '--never-download',
               base_dir]
    _Subprocess(command, 'Virtualenv creation failed.')
  
    # Set defaults for setuptools so that our built eggs get deposited
    # to the release directory, and so that installing looks there.
    opts = (
        # Tag eggs with the SVN revision by default.
        ('egg_info', 'tag-svn-revision', 'True'),
        # Drop created eggs in the base directory's parent dir (Debug or Release).
        ('bdist_egg', 'dist-dir', os.path.join(base_dir, '..')),
        # Tell easy install to use the parent dir as the package index by default.
        ('easy_install', 'index-url', os.path.join(base_dir, '..')),
      )
  
    for (cmd, option, value) in opts:
      command = [os.path.join(script_dir, 'python'),
                 '-c', 'from setuptools import setup; setup()',
                 'setopt',
                 '--global-config',
                 '--command', cmd,
                 '--option', option,
                 '--set-value', value]
      _Subprocess(command, 'Failed to set option %s' % option)
  
    # Hook numpy into the virtual environment by copying it in.
    try:
      numpy_dir = os.path.join(_SRC_DIR, 'third_party/numpy/files/numpy')
      site_lib_dir = os.path.join(base_dir, 'Lib/site-packages')
      shutil.copytree(numpy_dir, os.path.join(site_lib_dir, 'numpy'))
    except Exception:
      _LOGGER.exception('Unable to copy numpy.')
      raise VirtualEnvCreationError('Unable to copy numpy.')
  
    # Install matplotlib into the new environment. We use easy_install to do
    # the needful, but provide it with an index URL that's the directory
    # containing the matplotlib subdir.
    matplotlib_dir = os.path.abspath(os.path.join(_SRC_DIR, 'third_party'))
    command = [os.path.join(script_dir, 'easy_install'),
               '--index-url', matplotlib_dir,
               'matplotlib']
    _Subprocess(command, 'Matplotlib installation failed.')
function_tokens: def _CreateVirtualEnv ( base_dir ) : # We want all paths to be absolute. base_dir = os . path . abspath ( base_dir ) if os . path . exists ( base_dir ) : command = [ 'cmd' , '/c' , 'rmdir' , '/s' , '/q' , base_dir ] _Subprocess ( command , 'Failed to delete existing directory' ) # Start by creating the output directory and copying python26.dll, as well # as pywintypes26.dll into it, as if the DLLs are not in path, the virtual # environment won't work. script_dir = os . path . join ( base_dir , 'Scripts' ) try : os . makedirs ( script_dir ) dll_path = os . path . join ( os . path . dirname ( sys . executable ) , 'python26.dll' ) shutil . copy ( dll_path , script_dir ) dll_path = os . path . join ( os . path . dirname ( sys . executable ) , 'pywintypes26.dll' ) shutil . copy ( dll_path , script_dir ) dll_path = os . path . join ( os . path . dirname ( sys . executable ) , 'pythoncom26.dll' ) shutil . copy ( dll_path , script_dir ) except Exception : _LOGGER . exception ( 'Unable to copy python DLL' ) raise VirtualEnvCreationError ( 'Unable to copy python DLL' ) # Run virtualenv.py with our selfsame python interpreter. command = [ sys . executable , os . path . join ( _VIRTUALENV_DIR , 'virtualenv.py' ) , '--verbose' , '--never-download' , base_dir ] _Subprocess ( command , 'Virtualenv creation failed.' ) # Set defaults for setuptools so that our built eggs get deposited # to the release directory, and so that installing looks there. opts = ( # Tag eggs with the SVN revision by default. ( 'egg_info' , 'tag-svn-revision' , 'True' ) , # Drop created eggs in the base directory's parent dir (Debug or Release). ( 'bdist_egg' , 'dist-dir' , os . path . join ( base_dir , '..' ) ) , # Tell easy install to use the parent dir as the package index by default. ( 'easy_install' , 'index-url' , os . path . join ( base_dir , '..' ) ) , ) for ( cmd , option , value ) in opts : command = [ os . path . join ( script_dir , 'python' ) , '-c' , 'from setuptools import setup; setup()' , 'setopt' , '--global-config' , '--command' , cmd , '--option' , option , '--set-value' , value ] _Subprocess ( command , 'Failed to set option %s' % option ) # Hook numpy into the virtual environment by copying it in. try : numpy_dir = os . path . join ( _SRC_DIR , 'third_party/numpy/files/numpy' ) site_lib_dir = os . path . join ( base_dir , 'Lib/site-packages' ) shutil . copytree ( numpy_dir , os . path . join ( site_lib_dir , 'numpy' ) ) except Exception : _LOGGER . exception ( 'Unable to copy numpy.' ) raise VirtualEnvCreationError ( 'Unable to copy numpy.' ) # Install matplotlib into the new environment. We use easy_install to do # the needful, but provide it with an index URL that's the directory # containing the matplotlib subdir. matplotlib_dir = os . path . abspath ( os . path . join ( _SRC_DIR , 'third_party' ) ) command = [ os . path . join ( script_dir , 'easy_install' ) , '--index-url' , matplotlib_dir , 'matplotlib' ] _Subprocess ( command , 'Matplotlib installation failed.' )