pub(super) fn fetch_req_data(
        reqs: &[Req],
        vers_cache: &mut HashMap<String, (String, Version, Vec<Version>)>,
        py_vers: &Version,
    ) -> Result<Vec<ReqCache>, DependencyError> {
        // Narrow-down our list of versions to query.

        let mut query_data = HashMap::new();
        for req in reqs {
            // todo: cache version info; currently may get this multiple times.
            let (_, latest_version, all_versions) = match vers_cache.get(&req.name) {
                Some(c) => c.clone(),
                None => {
                    if let Ok(data) =
                        get_version_info(&req.name, Some(req.clone_or_default_py(py_vers)))
                    {
                        vers_cache.insert(req.name.clone(), data.clone());
                        data
                    } else {
                        util::abort(&format!(
                            "Can't get version info for the dependency `{}`. \
                         Is it spelled correctly? Is the internet connection ok?",
                            &req.name
                        ))
                    }
                }
            };

            let mut max_v_to_query = latest_version;

            // Find the maximum version compatible with the constraints.
            // todo: May need to factor in additional constraints here, and put
            // todo in fn signature for things that don't resolve with the optimal soln.
            for constr in &req.constraints {
                // For Ne, we have two ranges; the second one being ones higher than the version specified.
                // For other types, we only have one item in the compatible range.
                let i = match constr.type_ {
                    ReqType::Ne => 1,
                    _ => 0,
                };

                // Ensure we don't query past the latest.
                max_v_to_query = min(constr.compatible_range()[i].1.clone(), max_v_to_query);
            }

            // To minimimize request time, only query the latest compatible version.
            let best_version = match all_versions
                .into_iter()
                .filter(|v| *v <= max_v_to_query)
                .max()
            {
                Some(v) => vec![v],
                None => vec![],
            };

            query_data.insert(req.name.to_owned(), best_version);
        }

        if query_data.is_empty() {
            return Ok(vec![]);
        }

        Ok(get_req_cache_multiple(&query_data)?)
    }
/// Pull data on pydeps for a req. Only pull what we need.
/// todo: Group all reqs and pull with a single call to pydeps to improve speed?
Pull data on pydeps for a req. Only pull what we need.
Pull data on pydeps for a req . Only pull what we need .
pub(super) fn fetch_req_data(
        reqs: &[Req],
        vers_cache: &mut HashMap<String, (String, Version, Vec<Version>)>,
        py_vers: &Version,
    ) -> Result<Vec<ReqCache>, DependencyError> {
        // Narrow-down our list of versions to query.
        let mut query_data = HashMap::new();
        for req in reqs {
            // todo: cache version info; currently may get this multiple times.
            let (_, latest_version, all_versions) = match vers_cache.get(&req.name) {
                Some(c) => c.clone(),
                None => {
                    if let Ok(data) =
                        get_version_info(&req.name, Some(req.clone_or_default_py(py_vers)))
                    {
                        vers_cache.insert(req.name.clone(), data.clone());
                        data
                    } else {
                        util::abort(&format!(
                            "Can't get version info for the dependency `{}`. \
                         Is it spelled correctly? Is the internet connection ok?",
                            &req.name
                        ))
                    }
                }
            };
            let mut max_v_to_query = latest_version;
            // Find the maximum version compatible with the constraints.
            // todo: May need to factor in additional constraints here, and put
            // todo in fn signature for things that don't resolve with the optimal soln.
            for constr in &req.constraints {
                // For Ne, we have two ranges; the second one being ones higher than the version specified.
                // For other types, we only have one item in the compatible range.
                let i = match constr.type_ {
                    ReqType::Ne => 1,
                    _ => 0,
                };
                // Ensure we don't query past the latest.
                max_v_to_query = min(constr.compatible_range()[i].1.clone(), max_v_to_query);
            }
            // To minimimize request time, only query the latest compatible version.
            let best_version = match all_versions
                .into_iter()
                .filter(|v| *v <= max_v_to_query)
                .max()
            {
                Some(v) => vec![v],
                None => vec![],
            };
            query_data.insert(req.name.to_owned(), best_version);
        }
        if query_data.is_empty() {
            return Ok(vec![]);
        }
        Ok(get_req_cache_multiple(&query_data)?)
    }
pub ( super ) fn fetch_req_data ( reqs : & [ Req ] , vers_cache : & mut HashMap < String , ( String , Version , Vec < Version > ) > , py_vers : & Version , ) -> Result < Vec < ReqCache > , DependencyError > { // Narrow-down our list of versions to query. let mut query_data = HashMap :: new ( ) ; for req in reqs { // todo: cache version info; currently may get this multiple times. let ( _ , latest_version , all_versions ) = match vers_cache . get ( & req . name ) { Some ( c ) => c . clone ( ) , None => { if let Ok ( data ) = get_version_info ( & req . name , Some ( req . clone_or_default_py ( py_vers ) ) ) { vers_cache . insert ( req . name . clone ( ) , data . clone ( ) ) ; data } else { util :: abort ( & format ! ( " \
 " req name ) ) } } } ; let mut max_v_to_query = latest_version ; // Find the maximum version compatible with the constraints. // todo: May need to factor in additional constraints here, and put // todo in fn signature for things that don't resolve with the optimal soln. for constr in & req . constraints { // For Ne, we have two ranges; the second one being ones higher than the version specified. // For other types, we only have one item in the compatible range. let i = match constr . type_ { ReqType :: Ne => 1 , _ => 0 , } ; // Ensure we don't query past the latest. max_v_to_query = min ( constr . compatible_range ( ) [ i ] . 1 . clone ( ) , max_v_to_query ) ; } // To minimimize request time, only query the latest compatible version. let best_version = match all_versions . into_iter ( ) . filter ( | v | * v <= max_v_to_query ) . max ( ) { Some ( v ) => vec ! [ v ] , None => vec ! [ ] , } ; query_data . insert ( req . name . to_owned ( ) , best_version ) ; } if query_data . is_empty ( ) { return Ok ( vec ! [ ] ) ; } Ok ( get_req_cache_multiple ( & query_data ) ? ) }
Pull data on pydeps for a req.
Pull data on pydeps for a req .
reqs
&[Req]
vers_cache
&mut HashMap<String, (String, Version, Vec<Version>)>
py_vers
&Version
reqs
&[Req]
vers_cache
&mut HashMap<String, (String, Version, Vec<Version>)>
py_vers
&Version