@Override public void execute(ExecSpec execSpec) { if (OSDetector.isWindows()) { execSpec.args( "/MIR", "/NDL", "/NFL", "/NJH", "/NJS", "/NP", sourceDir.getAbsolutePath(), targetDir.getAbsolutePath()); execSpec.setExecutable("robocopy"); } else { execSpec.args( "--archive", "--delete", sourceDir.getAbsolutePath() + File.separator, targetDir.getAbsolutePath()); execSpec.setExecutable("rsync"); } execSpec.setIgnoreExitValue(true); }
@Override public void execute(ExecSpec execSpec) { if (OSDetector.isWindows()) { execSpec.args( "/MIR", "/NDL", "/NFL", "/NJH", "/NJS", "/NP", sourceDir.getAbsolutePath(), targetDir.getAbsolutePath()); execSpec.setExecutable("robocopy"); } else { execSpec.args( "--archive", "--delete", sourceDir.getAbsolutePath() + File.separator, targetDir.getAbsolutePath()); execSpec.setExecutable("rsync"); } 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); }
@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); }
@TaskAction public final void extractGraal() { if (!graalVersion.isPresent()) { throw new IllegalStateException("extract task requires graal.graalVersion to be defined."); } // ideally this would be a CopyTask, but through Gradle 4.9 CopyTask fails to correctly extract symlinks getProject().exec(spec -> { spec.executable("tar"); spec.args("-xzf", inputTgz.get().getAsFile().getAbsolutePath()); spec.workingDir(cacheDir.get().resolve(graalVersion.get())); }); }
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(); }); }
@TaskAction public final void nativeImage() throws IOException { List<String> args = new ArrayList<>(); args.add("-cp"); args.add(generateClasspathArgument()); args.add("-H:Path=" + maybeCreateOutputDirectory().getAbsolutePath()); if (outputName.isPresent()) { args.add("-H:Name=" + outputName.get()); } if (options.isPresent()) { List<String> optionList = options.get(); args.addAll(optionList); } args.add(mainClass.get()); getProject().exec(spec -> { spec.executable(getExecutable()); spec.args(args); }); }
@TaskAction public final void extractGraal() { if (!graalVersion.isPresent()) { throw new IllegalStateException("extract task requires graal.graalVersion to be defined."); } // ideally this would be a CopyTask, but through Gradle 4.9 CopyTask fails to correctly extract symlinks getProject().exec(spec -> { spec.executable("tar"); spec.args("-xzf", inputTgz.get().getAsFile().getAbsolutePath()); spec.workingDir(cacheDir.get().resolve(graalVersion.get())); }); }
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(); }); }
@TaskAction public final void nativeImage() throws IOException { List<String> args = new ArrayList<>(); args.add("-cp"); args.add(generateClasspathArgument()); args.add("-H:Path=" + maybeCreateOutputDirectory().getAbsolutePath()); if (outputName.isPresent()) { args.add("-H:Name=" + outputName.get()); } if (options.isPresent()) { List<String> optionList = options.get(); args.addAll(optionList); } args.add(mainClass.get()); getProject().exec(spec -> { spec.executable(getExecutable()); spec.args(args); }); }
@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); } }
private static void doProbe(Project project, PythonDetails pythonDetails, EditablePythonAbiContainer editablePythonAbiContainer) throws IOException { InputStream wheelApiResource = ProbeVenvInfoAction.class.getClassLoader() .getResourceAsStream("templates/wheel-api.py"); byte[] buffer = new byte[wheelApiResource.available()]; wheelApiResource.read(buffer); File probeDir = new File(project.getBuildDir(), "probe-venv"); probeDir.mkdirs(); OutputStream outStream = new FileOutputStream(getPythonFileForSupportedWheels(probeDir)); outStream.write(buffer); File supportedAbiFormatsFile = getSupportedAbiFormatsFile(probeDir, pythonDetails); project.exec(execSpec -> { execSpec.commandLine(pythonDetails.getVirtualEnvInterpreter()); execSpec.args(getPythonFileForSupportedWheels(probeDir)); execSpec.args(supportedAbiFormatsFile.getAbsolutePath()); }); JsonArray array = Json.parse(new FileReader(supportedAbiFormatsFile)).asArray(); for (JsonValue jsonValue : array) { JsonObject entry = jsonValue.asObject(); String pythonTag = entry.get("pythonTag").asString(); String abiTag = entry.get("abiTag").asString(); String platformTag = entry.get("platformTag").asString(); AbiDetails triple = new AbiDetails(pythonDetails.getVirtualEnvInterpreter(), pythonTag, abiTag, platformTag); editablePythonAbiContainer.addSupportedAbi(triple); } }
private static void doProbe(Project project, PythonDetails pythonDetails, EditablePythonAbiContainer editablePythonAbiContainer) throws IOException { InputStream wheelApiResource = ProbeVenvInfoAction.class.getClassLoader() .getResourceAsStream("templates/wheel-api.py"); byte[] buffer = new byte[wheelApiResource.available()]; wheelApiResource.read(buffer); File probeDir = new File(project.getBuildDir(), "probe-venv"); probeDir.mkdirs(); OutputStream outStream = new FileOutputStream(getPythonFileForSupportedWheels(probeDir)); outStream.write(buffer); File supportedAbiFormatsFile = getSupportedAbiFormatsFile(probeDir, pythonDetails); project.exec(execSpec -> { execSpec.commandLine(pythonDetails.getVirtualEnvInterpreter()); execSpec.args(getPythonFileForSupportedWheels(probeDir)); execSpec.args(supportedAbiFormatsFile.getAbsolutePath()); }); JsonArray array = Json.parse(new FileReader(supportedAbiFormatsFile)).asArray(); for (JsonValue jsonValue : array) { JsonObject entry = jsonValue.asObject(); String pythonTag = entry.get("pythonTag").asString(); String abiTag = entry.get("abiTag").asString(); String platformTag = entry.get("platformTag").asString(); AbiDetails triple = new AbiDetails(pythonDetails.getVirtualEnvInterpreter(), pythonTag, abiTag, platformTag); editablePythonAbiContainer.addSupportedAbi(triple); } }
@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); } });
@TaskAction public void executePythonProcess() { preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = externalExec.exec(execSpec -> { execSpec.environment(getComponent().pythonEnvironment); execSpec.environment(getComponent().pythonEnvironmentDistgradle); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); // subArguments are arguments for previous arguments. eg: arguments to py.test like -k execSpec.args(subArguments); // additionalArguments are same as subArguments, but are expected from user's build script execSpec.args(additionalArguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); output = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
@TaskAction public void executePythonProcess() { preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = externalExec.exec(execSpec -> { execSpec.environment(getComponent().pythonEnvironment); execSpec.environment(getComponent().pythonEnvironmentDistgradle); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); // subArguments are arguments for previous arguments. eg: arguments to py.test like -k execSpec.args(subArguments); // additionalArguments are same as subArguments, but are expected from user's build script execSpec.args(additionalArguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); output = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
@TaskAction public void executePythonProcess() { if (!isVenvReady()) { prepairVenv(); } preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = getProject().exec(execSpec -> { execSpec.environment(getPythonExtension().pythonEnvironment); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); lastMessage = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }
@TaskAction public void executePythonProcess() { if (!isVenvReady()) { prepairVenv(); } preExecution(); final TeeOutputContainer container = new TeeOutputContainer(stdOut, errOut); ExecResult result = getProject().exec(execSpec -> { execSpec.environment(getPythonExtension().pythonEnvironment); execSpec.commandLine(getPythonDetails().getVirtualEnvInterpreter()); // arguments are passed to the python interpreter execSpec.args(arguments); execSpec.setIgnoreExitValue(true); container.setOutputs(execSpec); configureExecution(execSpec); }); lastMessage = container.getCommandOutput(); if (!ignoreExitValue) { result.assertNormalExitValue(); } processResults(result); }