From e0902d7d5a7bf93092d16ceb81e7839e9b79b711 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 25 Jan 2024 09:47:46 -0800 Subject: [PATCH] Make `puffin-fs` `tokio` dependency opt-in (#1100) --- crates/puffin-client/Cargo.toml | 2 +- crates/puffin-distribution/Cargo.toml | 2 +- crates/puffin-fs/Cargo.toml | 6 +++++- crates/puffin-fs/src/lib.rs | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/puffin-client/Cargo.toml b/crates/puffin-client/Cargo.toml index 41f4e8188..3e6099cab 100644 --- a/crates/puffin-client/Cargo.toml +++ b/crates/puffin-client/Cargo.toml @@ -12,7 +12,7 @@ pep440_rs = { path = "../pep440-rs" } pep508_rs = { path = "../pep508-rs" } platform-tags = { path = "../platform-tags" } puffin-cache = { path = "../puffin-cache" } -puffin-fs = { path = "../puffin-fs" } +puffin-fs = { path = "../puffin-fs", features = ["tokio"] } puffin-normalize = { path = "../puffin-normalize" } pypi-types = { path = "../pypi-types" } diff --git a/crates/puffin-distribution/Cargo.toml b/crates/puffin-distribution/Cargo.toml index 8c4a28f2a..f82db64a7 100644 --- a/crates/puffin-distribution/Cargo.toml +++ b/crates/puffin-distribution/Cargo.toml @@ -23,7 +23,7 @@ platform-tags = { path = "../platform-tags" } puffin-cache = { path = "../puffin-cache" } puffin-client = { path = "../puffin-client" } puffin-extract = { path = "../puffin-extract" } -puffin-fs = { path = "../puffin-fs" } +puffin-fs = { path = "../puffin-fs", features = ["tokio"] } puffin-git = { path = "../puffin-git", features = ["vendored-openssl"] } puffin-normalize = { path = "../puffin-normalize" } puffin-traits = { path = "../puffin-traits" } diff --git a/crates/puffin-fs/Cargo.toml b/crates/puffin-fs/Cargo.toml index a6dedd55d..80178349a 100644 --- a/crates/puffin-fs/Cargo.toml +++ b/crates/puffin-fs/Cargo.toml @@ -16,8 +16,12 @@ workspace = true puffin-warnings = { path = "../puffin-warnings" } dunce = { workspace = true } -fs-err = { workspace = true, features = ["tokio"] } +fs-err = { workspace = true } fs2 = { workspace = true } junction = { workspace = true } tempfile = { workspace = true } tracing = { workspace = true } + +[features] +default = [] +tokio = ["fs-err/tokio"] diff --git a/crates/puffin-fs/src/lib.rs b/crates/puffin-fs/src/lib.rs index 8b4f08e43..7961c8df5 100644 --- a/crates/puffin-fs/src/lib.rs +++ b/crates/puffin-fs/src/lib.rs @@ -51,6 +51,7 @@ pub fn replace_symlink(src: impl AsRef, dst: impl AsRef) -> std::io: } /// Write `data` to `path` atomically using a temporary file and atomic rename. +#[cfg(feature = "tokio")] pub async fn write_atomic(path: impl AsRef, data: impl AsRef<[u8]>) -> std::io::Result<()> { let temp_file = NamedTempFile::new_in( path.as_ref()