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