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()); } }
protected GeneralCommandLine createCommandLine(Module module, List<String> params) throws ExecutionException { GeneralCommandLine cmd = new GeneralCommandLine(); Sdk sdk = PythonSdkType.findPythonSdk(module); if (sdk == null) { throw new ExecutionException("No sdk specified"); } ReSTService service = ReSTService.getInstance(module); cmd.setWorkDirectory( service.getWorkdir().isEmpty() ? module.getProject().getBaseDir().getPath() : service.getWorkdir()); PythonCommandLineState.createStandardGroupsIn(cmd); ParamsGroup script_params = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT); assert script_params != null; String commandPath = getCommandPath(sdk); if (commandPath == null) { throw new ExecutionException("Cannot find sphinx-quickstart."); } cmd.setExePath(commandPath); if (params != null) { for (String p : params) { script_params.addParameter(p); } } cmd.setPassParentEnvironment(true); setPythonIOEncoding(cmd.getEnvironment(), "utf-8"); setPythonUnbuffered(cmd.getEnvironment()); List<String> pathList = Lists.newArrayList(PythonCommandLineState.getAddedPaths(sdk)); pathList.addAll(PythonCommandLineState.collectPythonPath(module)); PythonCommandLineState.initPythonPath(cmd, true, pathList, sdk.getHomePath()); PythonSdkType.patchCommandLineForVirtualenv(cmd, sdk.getHomePath(), true); BuildoutFacet facet = BuildoutFacet.getInstance(module); if (facet != null) { facet.patchCommandLineForBuildout(cmd); } return cmd; }