Avoid caching wheel fetches

This commit is contained in:
Charlie Marsh 2023-10-06 00:50:13 -04:00
parent a43328d914
commit 28721cf5fc
6 changed files with 14 additions and 7 deletions

View file

@ -2,9 +2,9 @@ use std::path::Path;
use std::str::FromStr; use std::str::FromStr;
use anyhow::Result; use anyhow::Result;
use puffin_client::PypiClientBuilder;
use tracing::debug; use tracing::debug;
use puffin_client::PypiClientBuilder;
use puffin_interpreter::PythonExecutable; use puffin_interpreter::PythonExecutable;
use puffin_platform::tags::Tags; use puffin_platform::tags::Tags;
use puffin_platform::Platform; use puffin_platform::Platform;

View file

@ -3,10 +3,10 @@ use std::str::FromStr;
use anyhow::Result; use anyhow::Result;
use async_std::fs::File; use async_std::fs::File;
use install_wheel_rs::{install_wheel, InstallLocation};
use tracing::debug; use tracing::debug;
use url::Url; use url::Url;
use install_wheel_rs::{install_wheel, InstallLocation};
use puffin_client::PypiClientBuilder; use puffin_client::PypiClientBuilder;
use puffin_interpreter::PythonExecutable; use puffin_interpreter::PythonExecutable;
use puffin_platform::tags::Tags; use puffin_platform::tags::Tags;

View file

@ -111,8 +111,7 @@ impl PypiClient {
url: &Url, url: &Url,
) -> Result<Box<dyn AsyncRead + Unpin + Send + Sync>, PypiClientError> { ) -> Result<Box<dyn AsyncRead + Unpin + Send + Sync>, PypiClientError> {
Ok(Box::new( Ok(Box::new(
// TODO(charlie): Use an uncached client. self.uncached_client
self.client
.get(url.to_string()) .get(url.to_string())
.send() .send()
.await? .await?

View file

@ -66,7 +66,7 @@ impl PypiClientBuilder {
let retry_strategy = RetryTransientMiddleware::new_with_policy(retry_policy); let retry_strategy = RetryTransientMiddleware::new_with_policy(retry_policy);
let mut client_builder = let mut client_builder =
reqwest_middleware::ClientBuilder::new(client_raw).with(retry_strategy); reqwest_middleware::ClientBuilder::new(client_raw.clone()).with(retry_strategy);
if let Some(path) = self.cache { if let Some(path) = self.cache {
client_builder = client_builder.with(Cache(HttpCache { client_builder = client_builder.with(Cache(HttpCache {
@ -76,10 +76,17 @@ impl PypiClientBuilder {
})); }));
} }
let retry_policy = ExponentialBackoff::builder().build_with_max_retries(self.retries);
let retry_strategy = RetryTransientMiddleware::new_with_policy(retry_policy);
let uncached_client_builder =
reqwest_middleware::ClientBuilder::new(client_raw).with(retry_strategy);
PypiClient { PypiClient {
registry: Arc::new(self.registry), registry: Arc::new(self.registry),
proxy: Arc::new(self.proxy), proxy: Arc::new(self.proxy),
client: client_builder.build(), client: client_builder.build(),
uncached_client: uncached_client_builder.build(),
} }
} }
} }
@ -89,4 +96,5 @@ pub struct PypiClient {
pub(crate) registry: Arc<Url>, pub(crate) registry: Arc<Url>,
pub(crate) proxy: Arc<Url>, pub(crate) proxy: Arc<Url>,
pub(crate) client: ClientWithMiddleware, pub(crate) client: ClientWithMiddleware,
pub(crate) uncached_client: ClientWithMiddleware,
} }

View file

@ -1,8 +1,9 @@
use std::str::FromStr; use std::str::FromStr;
use puffin_platform::tags::Tags;
use thiserror::Error; use thiserror::Error;
use puffin_platform::tags::Tags;
#[derive(Debug, Clone, Eq, PartialEq)] #[derive(Debug, Clone, Eq, PartialEq)]
pub struct WheelFilename { pub struct WheelFilename {
pub distribution: String, pub distribution: String,

View file

@ -1,5 +1,4 @@
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::str::FromStr; use std::str::FromStr;
use anyhow::Result; use anyhow::Result;