private void checkPipStatus()

in src/main/java/com/awslabs/general/helpers/implementations/BasicLambdaPackagingHelper.java [143:193]


    private void checkPipStatus(Option<ProcessOutput> processOutputOption) {
        if (processOutputOption.isEmpty()) {
            log.error("pip failed to start, cannot continue.");
            System.exit(1);
        }

        ProcessOutput processOutput = processOutputOption.get();

        if (processOutput.getExitCode() == 0) {
            // Success!
            return;
        }

        // Some kind of failure, investigate
        log.error("Something went wrong with pip");

        List<String> stdoutStrings = processOutput.getStandardOutStrings();
        List<String> stderrStrings = processOutput.getStandardErrorStrings();

        if (stderrStrings.find(string -> string.contains("'clang' failed")).isDefined()) {
            stdoutStrings.forEach(log::warn);
            stderrStrings.forEach(log::error);

            log.error("Building this function failed because a dependency failed to compile. This can happen when a dependency needs to build a native library. Error messages are above.");

            System.exit(1);
        }

        if (stderrStrings.find(string -> string.contains("Could not find a version that satisfies the requirement")).isDefined() ||
                stderrStrings.find(string -> string.contains("No matching distribution found")).isDefined()) {
            stdoutStrings.forEach(log::warn);
            stderrStrings.forEach(log::error);

            log.error("Building this function failed because a dependency was not available. Error messages are above.");

            System.exit(1);
        }

        if (isCorrectPipVersion()) {
            log.error("pip version is correct but the Python dependency failed to install");
        } else {
            log.error("pip version appears to be incorrect or pip is missing");
        }

        log.error("To resolve:");
        log.error("1) Make sure Python and pip are installed and on your path");
        log.error("2) Make sure pip version is 19.x (pip --version) and install it with get-pip.py if necessary (https://pip.pypa.io/en/stable/installing/)");
        log.error("3) Try installing the dependency with pip and see if pip returns any installation errors");

        System.exit(1);
    }