public static void patchCommandLineForVirtualenv(GeneralCommandLine commandLine,String sdkHome,boolean passParentEnvironment){
  File virtualEnvRoot=getVirtualEnvRoot(sdkHome);
  if (virtualEnvRoot != null) {
    @NonNls final String PATH="PATH";
    File bin=new File(virtualEnvRoot,"bin");
    if (!bin.exists()) {
      bin=new File(virtualEnvRoot,"Scripts");
    }
    String virtualenvBin=bin.getPath();
    Map<String,String> env=commandLine.getEnvironment();
    String pathValue;
    if (env.containsKey(PATH)) {
      pathValue=PythonEnvUtil.appendToPathEnvVar(env.get(PATH),virtualenvBin);
    }
 else     if (passParentEnvironment) {
      pathValue=PythonEnvUtil.appendToPathEnvVar(System.getenv(PATH),virtualenvBin);
    }
 else {
      pathValue=virtualenvBin;
    }
    env.put(PATH,pathValue);
  }
}

public static void patchCommandLineForVirtualenv ( GeneralCommandLine commandLine , String sdkHome , boolean passParentEnvironment ) { File virtualEnvRoot = getVirtualEnvRoot ( sdkHome ) ; if ( virtualEnvRoot != null ) { @ NonNls final String PATH = "PATH" ; File bin = new File ( virtualEnvRoot , "bin" ) ; if ( ! bin . exists ( ) ) { bin = new File ( virtualEnvRoot , "Scripts" ) ; } String virtualenvBin = bin . getPath ( ) ; Map < String , String > env = commandLine . getEnvironment ( ) ; String pathValue ; if ( env . containsKey ( PATH ) ) { pathValue = PythonEnvUtil . appendToPathEnvVar ( env . get ( PATH ) , virtualenvBin ) ; } else if ( passParentEnvironment ) { pathValue = PythonEnvUtil . appendToPathEnvVar ( System . getenv ( PATH ) , virtualenvBin ) ; } else { pathValue = virtualenvBin ; } env . put ( PATH , pathValue ) ; } }
alters path so that a virtualenv is activated , if present .
