pygradle-plugin/src/main/groovy/com/linkedin/gradle/python/wheel/FileBackedWheelCache.java
public Optional<File> findWheel(String name, String version, File pythonExecutable) {
        if (cacheDir == null) {
            return Optional.empty();
        }

        /*
         * NOTE: Careful here! The prefix *must* end with a hyphen.
         * Otherwise 0.0.2 version will match 0.0.20.
         * Both name and version of the package must replace hyphen with underscore.
         * See PEP 427: https://www.python.org/dev/peps/pep-0427/
         */
        String wheelPrefix = (
                name.replace("-", "_")
                + "-"
                + version.replace("-", "_")
                + "-"
        );
        logger.info("Searching for {} {} with prefix {}", name, version, wheelPrefix);
        File[] files = cacheDir.listFiles((dir, entry) -> entry.startsWith(wheelPrefix) && entry.endsWith(".whl"));

        if (files == null) {
            return Optional.empty();
        }

        List<PythonWheelDetails> wheelDetails = Arrays.stream(files).map(PythonWheelDetails::fromFile)
            .filter(Optional::isPresent)
            .map(Optional::get)
            .collect(Collectors.toList());

        logger.info("Wheels for version of package: {}", wheelDetails);

        Optional<PythonWheelDetails> foundWheel = wheelDetails.stream()
            .filter(it -> wheelMatches(pythonExecutable, it))
            .findFirst();

        logger.info("Found artifacts: {}", foundWheel);

        return foundWheel.map(it -> it.getFile());
    }
/**
     * Finds a wheel in the cache.
     *
     * @param name package name
     * @param version package version
     * @param pythonExecutable Python interpreter executable file
     * @return the wheel if found in the cache, otherwise {@code Optional.empty()}
     */
Finds a wheel in the cache.
@param name package name
@param version package version
@param pythonExecutable Python interpreter executable file
@return the wheel if found in the cache, otherwise  Optional.empty()
Finds a wheel in the cache . @param name package name @param version package version @param pythonExecutable Python interpreter executable file @return the wheel if found in the cache otherwise Optional . empty ()
public Optional<File> findWheel(String name, String version, File pythonExecutable) {
        if (cacheDir == null) {
            return Optional.empty();
        }
        /*
         * NOTE: Careful here! The prefix *must* end with a hyphen.
         * Otherwise 0.0.2 version will match 0.0.20.
         * Both name and version of the package must replace hyphen with underscore.
         * See PEP 427: https://www.python.org/dev/peps/pep-0427/
         */
        String wheelPrefix = (
                name.replace("-", "_")
                + "-"
                + version.replace("-", "_")
                + "-"
        );
        logger.info("Searching for {} {} with prefix {}", name, version, wheelPrefix);
        File[] files = cacheDir.listFiles((dir, entry) -> entry.startsWith(wheelPrefix) && entry.endsWith(".whl"));
        if (files == null) {
            return Optional.empty();
        }
        List<PythonWheelDetails> wheelDetails = Arrays.stream(files).map(PythonWheelDetails::fromFile)
            .filter(Optional::isPresent)
            .map(Optional::get)
            .collect(Collectors.toList());
        logger.info("Wheels for version of package: {}", wheelDetails);
        Optional<PythonWheelDetails> foundWheel = wheelDetails.stream()
            .filter(it -> wheelMatches(pythonExecutable, it))
            .findFirst();
        logger.info("Found artifacts: {}", foundWheel);
        return foundWheel.map(it -> it.getFile());
    }
public Optional < File > findWheel ( String name , String version , File pythonExecutable ) { if ( cacheDir == null ) { return Optional . empty ( ) ; } /*
         * NOTE: Careful here! The prefix *must* end with a hyphen.
         * Otherwise 0.0.2 version will match 0.0.20.
         * Both name and version of the package must replace hyphen with underscore.
         * See PEP 427: https://www.python.org/dev/peps/pep-0427/
         */ String wheelPrefix = ( name . replace ( "-" , "_" ) + "-" + version . replace ( "-" , "_" ) + "-" ) ; logger . info ( "Searching for {} {} with prefix {}" , name , version , wheelPrefix ) ; File [ ] files = cacheDir . listFiles ( ( dir , entry ) -> entry . startsWith ( wheelPrefix ) && entry . endsWith ( ".whl" ) ) ; if ( files == null ) { return Optional . empty ( ) ; } List < PythonWheelDetails > wheelDetails = Arrays . stream ( files ) . map ( PythonWheelDetails :: fromFile ) . filter ( Optional :: isPresent ) . map ( Optional :: get ) . collect ( Collectors . toList ( ) ) ; logger . info ( "Wheels for version of package: {}" , wheelDetails ) ; Optional < PythonWheelDetails > foundWheel = wheelDetails . stream ( ) . filter ( it -> wheelMatches ( pythonExecutable , it ) ) . findFirst ( ) ; logger . info ( "Found artifacts: {}" , foundWheel ) ; return foundWheel . map ( it -> it . getFile ( ) ) ; }
Finds a wheel in the cache.
Finds a wheel in the cache .