mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 05:15:00 +00:00
Migrate to tokio
(#27)
Closes https://github.com/astral-sh/puffin/issues/26.
This commit is contained in:
parent
ca6aa207ff
commit
dd26cfa0cc
7 changed files with 12 additions and 15 deletions
|
@ -13,11 +13,6 @@ license = "MIT OR Apache-2.0"
|
|||
|
||||
[workspace.dependencies]
|
||||
anyhow = { version = "1.0.75" }
|
||||
async-std = { version = "1.12.0", features = [
|
||||
"attributes",
|
||||
"tokio1",
|
||||
"unstable",
|
||||
] }
|
||||
bitflags = { version = "2.4.0" }
|
||||
clap = { version = "4.4.6" }
|
||||
colored = { version = "2.0.4" }
|
||||
|
@ -44,6 +39,8 @@ serde_json = { version = "1.0.107" }
|
|||
target-lexicon = { version = "0.12.11" }
|
||||
tempfile = { version = "3.8.0" }
|
||||
thiserror = { version = "1.0.49" }
|
||||
tokio = { version = "1.16.1", features = ["rt-multi-thread"] }
|
||||
tokio-util = { version = "0.7.9", features = ["compat"] }
|
||||
tracing = { version = "0.1.37" }
|
||||
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||
tracing-tree = { version = "0.2.5" }
|
||||
|
|
|
@ -22,7 +22,7 @@ To compare a warm run of `puffin` to `pip`:
|
|||
|
||||
```shell
|
||||
hyperfine --runs 10 --warmup 3 \
|
||||
"./target/release/puffin-cli install requirements.txt" \
|
||||
"./target/release/puffin-cli sync requirements.txt" \
|
||||
"pip install -r requirements.txt"
|
||||
```
|
||||
|
||||
|
@ -30,7 +30,7 @@ To compare a cold run of `puffin` to `pip`:
|
|||
|
||||
```shell
|
||||
hyperfine --runs 10 --warmup 3 \
|
||||
"./target/release/puffin-cli install requirements.txt --no-cache" \
|
||||
"./target/release/puffin-cli sync requirements.txt --no-cache" \
|
||||
"pip install -r requirements.txt --ignore-installed --no-cache-dir"
|
||||
```
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ puffin-package = { path = "../puffin-package" }
|
|||
puffin-resolver = { path = "../puffin-resolver" }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
async-std = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
colored = { workspace = true }
|
||||
directories = { workspace = true }
|
||||
|
@ -25,3 +24,4 @@ tracing-tree = { workspace = true }
|
|||
tracing-subscriber = { workspace = true }
|
||||
url = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
|
|
@ -9,8 +9,7 @@ pub(crate) fn setup_logging() -> Result<()> {
|
|||
let targets = Targets::new()
|
||||
.with_target("hyper", LevelFilter::WARN)
|
||||
.with_target("reqwest", LevelFilter::WARN)
|
||||
.with_target("async_io", LevelFilter::WARN)
|
||||
.with_target("async_std", LevelFilter::WARN)
|
||||
.with_target("tokio", LevelFilter::WARN)
|
||||
.with_target("blocking", LevelFilter::OFF)
|
||||
.with_default(LevelFilter::TRACE);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ struct SyncArgs {
|
|||
no_cache: bool,
|
||||
}
|
||||
|
||||
#[async_std::main]
|
||||
#[tokio::main]
|
||||
async fn main() -> ExitCode {
|
||||
let cli = Cli::parse();
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@ puffin-client = { path = "../puffin-client" }
|
|||
puffin-interpreter = { path = "../puffin-interpreter" }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
async-std = { workspace = true }
|
||||
install-wheel-rs = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
url = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio-util = { workspace = true }
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::str::FromStr;
|
|||
|
||||
use anyhow::Result;
|
||||
use install_wheel_rs::{install_wheel, InstallLocation};
|
||||
use tokio_util::compat::FuturesAsyncReadCompatExt;
|
||||
use url::Url;
|
||||
|
||||
use puffin_client::{File, PypiClient};
|
||||
|
@ -24,9 +25,8 @@ pub async fn install(
|
|||
let reader = client.stream_external(&url).await?;
|
||||
|
||||
// TODO(charlie): Stream the unzip.
|
||||
let mut writer =
|
||||
async_std::fs::File::create(tmp_dir.path().join(&wheel.hashes.sha256)).await?;
|
||||
async_std::io::copy(reader, &mut writer).await?;
|
||||
let mut writer = tokio::fs::File::create(tmp_dir.path().join(&wheel.hashes.sha256)).await?;
|
||||
tokio::io::copy(&mut reader.compat(), &mut writer).await?;
|
||||
}
|
||||
|
||||
// Install each wheel.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue