public void setOutputs(ExecSpec execSpec) { execSpec.setStandardOutput(teeStdOut); execSpec.setErrorOutput(teeErrOut); }
public void setOutputs(ExecSpec execSpec) { execSpec.setStandardOutput(teeStdOut); execSpec.setErrorOutput(teeErrOut); }
private static String exec(Project project, String executable, String... args) { ByteArrayOutputStream out = new ByteArrayOutputStream(); project.exec(execSpec -> { execSpec.setExecutable(executable); execSpec.setArgs(Arrays.asList(args)); execSpec.setStandardOutput(out); }); return out.toString(); }
@Override public void execute(ExecSpec execSpec) { if (_environment != null) { execSpec.environment(_environment); } execSpec.setCommandLine(_commandLine); execSpec.setStandardOutput(byteArrayOutputStream); }
@Override public void accept(File file) { if (distutilsCfg != null) { final Path path = file.toPath(); try { Files.write(path.resolve( Paths.get("virtualenv_embedded", "distutils.cfg")), distutilsCfg.getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { throw new UncheckedIOException(e); } final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exec.exec(execSpec -> { execSpec.commandLine(pythonDetails.getSystemPythonInterpreter(), path.resolve(Paths.get("bin", "rebuild-script.py")).toFile()); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); }); log.info("Customized distutils.cfg"); } } }
@Override public void accept(File file) { if (distutilsCfg != null) { final Path path = file.toPath(); try { Files.write(path.resolve( Paths.get("virtualenv_embedded", "distutils.cfg")), distutilsCfg.getBytes(), StandardOpenOption.APPEND); } catch (IOException e) { throw new UncheckedIOException(e); } final ByteArrayOutputStream stream = new ByteArrayOutputStream(); exec.exec(execSpec -> { execSpec.commandLine(pythonDetails.getSystemPythonInterpreter(), path.resolve(Paths.get("bin", "rebuild-script.py")).toFile()); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); }); log.info("Customized distutils.cfg"); } } }
public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.setExecutable(pythonInterpreter.getAbsolutePath()); execSpec.setArgs(Collections.singletonList("--version")); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }); String output = outputStream.toString(); if (execResult.getExitValue() != 0) { throw new GradleException(output); } String versionString = output.trim().split(" ")[1]; return new PythonVersion(versionString); } }
public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ExecResult execResult = project.exec(execSpec -> { execSpec.setExecutable(pythonInterpreter.getAbsolutePath()); execSpec.setArgs(Collections.singletonList("--version")); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }); String output = outputStream.toString(); if (execResult.getExitValue() != 0) { throw new GradleException(output); } String versionString = output.trim().split(" ")[1]; return new PythonVersion(versionString); } }
public ParallelWheelGenerationTask() { onlyIf(task -> { ByteArrayOutputStream stdOut = new ByteArrayOutputStream(); getProject().exec(execSpec -> { execSpec.setExecutable(getPythonDetails().getVirtualEnvInterpreter()); execSpec.args(getPythonDetails().getVirtualEnvironment().getPip(), "freeze", "--all"); execSpec.setStandardOutput(stdOut); }); Configuration requiredDependencies = getProject().getConfigurations() .getByName(CONFIGURATION_SETUP_REQS.getValue()); Set<String> setupRequiresDependencies = requiredDependencies.getIncoming().getDependencies().stream() .flatMap(it -> Stream.of(it.getName(), it.getName().replace("-", "_"))) .collect(Collectors.toSet()); Set<String> extraDependencies = Arrays.stream(stdOut.toString().trim().split(System.lineSeparator())) .filter(it -> it.contains("==")).map(it -> it.split("==")[0]) .filter(it -> !setupRequiresDependencies.contains(it)) .collect(Collectors.toSet()); if (!extraDependencies.isEmpty()) { logger.info("Extra dependencies found ({}). Skipping parallel wheel building.", extraDependencies); } return extraDependencies.isEmpty(); }); }
@Override public void execute(ExecSpec execSpec) { /* * Gradle doesn't work correctly when there are empty args. */ List<String> args = processInfo.getArgs().stream() .map(a -> a.isEmpty()? "\"\"" : a) .collect(Collectors.toList()); execSpec.setExecutable(processInfo.getExecutable()); execSpec.args(args); execSpec.environment(processInfo.getEnvironment()); execSpec.setStandardOutput(processOutput.getStandardOutput()); execSpec.setErrorOutput(processOutput.getErrorOutput()); // we want the caller to be able to do its own thing. execSpec.setIgnoreExitValue(true); } }
@Override public void execute(ExecSpec execSpec) { execSpec.commandLine(pythonExtension.getDetails().getVirtualEnvInterpreter()); execSpec.args(pythonExtension.getDetails().getVirtualEnvironment().getPex()); System.out.println(outputFile.getAbsolutePath()); execSpec.args(Arrays.asList("--no-pypi", "--cache-dir", pexCache.getAbsolutePath(), "--output-file", outputFile.getAbsolutePath(), "--repo", wheelCache.getAbsolutePath(), "--python-shebang", pexShebang.getAbsolutePath())); if (entryPoint != null) { execSpec.args(Arrays.asList("--entry-point", entryPoint)); } execSpec.args(pexOptions); execSpec.args(pexRequirements(dependencies)); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }
ExecResult execCommand(Map<String, String> mergedEnv, List<String> commandLine, OutputStream stream) { return externalExec.exec(execSpec -> { execSpec.environment(mergedEnv); execSpec.commandLine(commandLine); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); execSpec.setIgnoreExitValue(true); }); }
@Override public void execute(ExecSpec execSpec) { execSpec.commandLine(pythonExtension.getDetails().getVirtualEnvInterpreter()); execSpec.args(pythonExtension.getDetails().getVirtualEnvironment().getPex()); System.out.println(outputFile.getAbsolutePath()); execSpec.args(Arrays.asList("--no-pypi", "--cache-dir", pexCache.getAbsolutePath(), "--output-file", outputFile.getAbsolutePath(), "--repo", wheelCache.getAbsolutePath(), "--python-shebang", pexShebang.getAbsolutePath())); if (entryPoint != null) { execSpec.args(Arrays.asList("--entry-point", entryPoint)); } execSpec.args(pexOptions); execSpec.args(pexRequirements(dependencies)); execSpec.setStandardOutput(outputStream); execSpec.setErrorOutput(outputStream); execSpec.setIgnoreExitValue(true); }
ExecResult execCommand(Map<String, String> mergedEnv, List<String> commandLine, OutputStream stream) { return externalExec.exec(execSpec -> { execSpec.environment(mergedEnv); execSpec.commandLine(commandLine); execSpec.setStandardOutput(stream); execSpec.setErrorOutput(stream); execSpec.setIgnoreExitValue(true); }); }
@Override public void execute(ExecSpec execSpec) { if (workingDirectory != null) { execSpec.setWorkingDir(workingDirectory); } execSpec.setCommandLine((Object[])Commandline.translateCommandline(command)); execSpec.setIgnoreExitValue(ignoreExitValue); if (logStandardOutput) { execSpec.setStandardOutput(standardOutputStream); } execSpec.setErrorOutput(errorOutputStream); } });
@Override public void execute(final ExecSpec it) { it.setExecutable(info.getShellExecutable()); if (isWindows()) { it.environment("MSYSTEM", mSystem); it.environment("CHERE_INVOKING", "1"); } it.args(getAllArgs()); if (!workingDir.isDirectory()) { workingDir.mkdirs(); } it.setWorkingDir(workingDir); it.setStandardInput(standardInput); it.setStandardOutput(standardOutput); it.setErrorOutput(errorOutput); } });
@Override public void execute(ExecSpec execSpec) { execSpec.setCommandLine(_getCommandLine()); execSpec.setEnvironment( _getEnvironment(execSpec.getEnvironment())); execSpec.setErrorOutput( new TeeOutputStream(byteArrayOutputStream, System.out)); execSpec.setStandardOutput( new TeeOutputStream(byteArrayOutputStream, System.out)); execSpec.setWorkingDir(getWorkingDir()); }
@Override public void execute(ExecSpec execSpec) { execSpec.setCommandLine(_getCommandLine()); execSpec.setEnvironment( _getEnvironment(execSpec.getEnvironment())); execSpec.setErrorOutput( new TeeOutputStream(byteArrayOutputStream, System.out)); execSpec.setStandardOutput( new TeeOutputStream(byteArrayOutputStream, System.out)); execSpec.setWorkingDir(getWorkingDir()); }
@Override public void execute(ExecSpec spec) { spec.setIgnoreExitValue(true); spec.commandLine(execCommand.getCommandLine()); spec.setStandardOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.out)); spec.setErrorOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.err)); execCommand.getSetupAction().execute(spec); LOG.lifecycle(" " + execCommand.getDescription() + ":\n " + StringUtil.join(execCommand.getCommandLine(), " ")); } });
@Override public void execute(ExecSpec spec) { spec.setIgnoreExitValue(true); spec.commandLine(execCommand.getCommandLine()); spec.setStandardOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.out)); spec.setErrorOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.err)); execCommand.getSetupAction().execute(spec); LOG.lifecycle(" " + execCommand.getDescription() + ":\n " + StringUtil.join(execCommand.getCommandLine(), " ")); } });