void (@NotNull Project project) { try { final RunManager runManager = RunManager.getInstance(project); final RunnerAndConfigurationSettings selectedConfiguration = runManager.getSelectedConfiguration(); if (selectedConfiguration == null) { throw new ExecutionException(PyBundle.message("debugger.cython.python.run.configuration.should.be.selected")); } final RunConfiguration configuration = selectedConfiguration.getConfiguration(); if (!(configuration instanceof AbstractPythonRunConfiguration runConfiguration)) { throw new ExecutionException(PyBundle.message("debugger.cython.python.run.configuration.should.be.selected")); } final String interpreterPath = runConfiguration.getInterpreterPath(); final String helpersPath = PythonHelpersLocator.getHelpersRoot().getPath(); final String cythonExtensionsDir = PyDebugRunner.CYTHON_EXTENSIONS_DIR; final String[] cythonArgs = {"build_ext", "--build-lib", cythonExtensionsDir, "--build-temp", String.format("%s%sbuild", cythonExtensionsDir, File.separator)}; final List<String> cmdline = new ArrayList<>(); cmdline.add(interpreterPath); cmdline.add(FileUtil.join(helpersPath, FileUtil.toSystemDependentName(SETUP_CYTHON_PATH))); cmdline.addAll(Arrays.asList(cythonArgs)); LOG.info("Compile Cython Extensions " + StringUtil.join(cmdline, " ")); final Map<String, String> environment = new HashMap<>(System.getenv()); PythonEnvUtil.addToPythonPath(environment, cythonExtensionsDir); PythonEnvUtil.setPythonUnbuffered(environment); PythonEnvUtil.setPythonDontWriteBytecode(environment); if (interpreterPath != null) { PythonEnvUtil.resetHomePathChanges(interpreterPath, environment); } GeneralCommandLine commandLine = new GeneralCommandLine(cmdline).withEnvironment(environment); final boolean canCreate = FileUtil.ensureCanCreateFile(new File(cythonExtensionsDir)); final boolean useSudo = !canCreate && !SystemInfo.isWindows; Process process; if (useSudo) { process = ExecUtil.sudo(commandLine, PyBundle.message("debugger.cython.please.enter.your.password.to.compile.cython.extensions")); } else { process = commandLine.createProcess(); } ProgressManager.getInstance().run(new Task.Backgroundable(project, PyBundle.message("compile.cython.extensions.title")) { @Override public void run(@NotNull ProgressIndicator indicator) { final CapturingProcessHandler handler = new CapturingProcessHandler(process, commandLine.getCharset(), commandLine.getCommandLineString()); handler.addProcessListener(new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.STDOUT || outputType == ProcessOutputTypes.STDERR) { for (String line : StringUtil.splitByLines(event.getText())) { if (isSignificantOutput(line)) { indicator.setText2(line.trim()); //NON-NLS } } } } private static boolean isSignificantOutput(String line) { return line.trim().length() > 3; } }); final ProcessOutput result = handler.runProcessWithProgressIndicator(indicator); final int exitCode = result.getExitCode(); if (exitCode != 0) { final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ? PyBundle.message("debugger.cython.extension.permission.denied") : PyBundle.message("debugger.cython.extension.non.zero.exit.code", exitCode, result.getStderr()); UIUtil.invokeLaterIfNeeded(() -> showClearErrorMessage(message, project)); } } }); } catch (IOException | ExecutionException e) { showClearErrorMessage(e.getMessage(), project); } }