private static void buildPythonPath(
     Project project, GeneralCommandLine commandLine, PythonRunParams config) {
   Sdk pythonSdk = PythonSdkType.findSdkByPath(config.getSdkHome());
   if (pythonSdk != null) {
     List<String> pathList = Lists.newArrayList(getAddedPaths(pythonSdk));
     pathList.addAll(collectPythonPath(project, config));
     initPythonPath(commandLine, config.isPassParentEnvs(), pathList, config.getSdkHome());
   }
 }
  @Nullable
  public static String getInterpreterPath(Project project, PythonRunParams config) {
    String sdkHome = config.getSdkHome();
    if (config.isUseModuleSdk() || StringUtil.isEmpty(sdkHome)) {
      Module module = getModule(project, config);

      Sdk sdk = PythonSdkType.findPythonSdk(module);
      if (sdk == null) return null;
      sdkHome = sdk.getHomePath();
    }

    return sdkHome;
  }
 @Nullable
 private static Module getModule(Project project, PythonRunParams config) {
   String name = config.getModuleName();
   return StringUtil.isEmpty(name)
       ? null
       : ModuleManager.getInstance(project).findModuleByName(name);
 }
  protected static void initEnvironment(
      Project project, GeneralCommandLine commandLine, PythonRunParams myConfig) {
    Map<String, String> env = myConfig.getEnvs();
    if (env == null) {
      env = new HashMap<String, String>();
    } else {
      env = new HashMap<String, String>(env);
    }

    setupEncodingEnvs(env, commandLine.getCharset());

    addCommonEnvironmentVariables(env);

    commandLine.getEnvironment().clear();
    commandLine.getEnvironment().putAll(env);
    commandLine.withParentEnvironmentType(
        myConfig.isPassParentEnvs() ? ParentEnvironmentType.CONSOLE : ParentEnvironmentType.NONE);

    buildPythonPath(project, commandLine, myConfig);
  }
  protected static Collection<String> collectPythonPath(Project project, PythonRunParams config) {
    final Module module = getModule(project, config);

    return Sets.newHashSet(
        collectPythonPath(module, config.shouldAddContentRoots(), config.shouldAddSourceRoots()));
  }