diff --git a/Cargo.lock b/Cargo.lock index a2f188be3..d5f42c18e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2454,24 +2454,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "path-absolutize" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" -dependencies = [ - "path-dedot", -] - -[[package]] -name = "path-dedot" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" -dependencies = [ - "once_cell", -] - [[package]] name = "path-slash" version = "0.2.1" @@ -4892,7 +4874,6 @@ dependencies = [ "fs-err", "fs2", "junction", - "path-absolutize", "path-slash", "serde", "tempfile", diff --git a/Cargo.toml b/Cargo.toml index 142a15513..b17221a98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,7 +106,6 @@ memchr = { version = "2.7.4" } miette = { version = "7.2.0" } nanoid = { version = "0.4.0" } owo-colors = { version = "4.0.0" } -path-absolutize = { version = "3.1.1" } path-slash = { version = "0.2.1" } pathdiff = { version = "0.2.1" } petgraph = { version = "0.6.4" } diff --git a/crates/uv-distribution/src/metadata/lowering.rs b/crates/uv-distribution/src/metadata/lowering.rs index c0caf4119..3d81a1a6a 100644 --- a/crates/uv-distribution/src/metadata/lowering.rs +++ b/crates/uv-distribution/src/metadata/lowering.rs @@ -9,7 +9,6 @@ use distribution_filename::DistExtension; use pep440_rs::VersionSpecifiers; use pep508_rs::{VerbatimUrl, VersionOrUrl}; use pypi_types::{ParsedUrlError, Requirement, RequirementSource, VerbatimParsedUrl}; -use uv_fs::Simplified; use uv_git::GitReference; use uv_normalize::PackageName; use uv_warnings::warn_user_once; @@ -250,8 +249,6 @@ pub enum LoweringError { InvalidVerbatimUrl(#[from] pep508_rs::VerbatimUrlError), #[error("Can't combine URLs from both `project.dependencies` and `tool.uv.sources`")] ConflictingUrls, - #[error("Could not normalize path: `{}`", _0.user_display())] - Absolutize(PathBuf, #[source] io::Error), #[error("Fragments are not allowed in URLs: `{0}`")] ForbiddenFragment(Url), #[error("`workspace = false` is not yet supported")] diff --git a/crates/uv-fs/Cargo.toml b/crates/uv-fs/Cargo.toml index 3b2c58a13..e95382bbc 100644 --- a/crates/uv-fs/Cargo.toml +++ b/crates/uv-fs/Cargo.toml @@ -22,7 +22,6 @@ either = { workspace = true } encoding_rs_io = { workspace = true } fs-err = { workspace = true } fs2 = { workspace = true } -path-absolutize = { workspace = true } path-slash = { workspace = true } serde = { workspace = true, optional = true } tempfile = { workspace = true } diff --git a/crates/uv-fs/src/path.rs b/crates/uv-fs/src/path.rs index 25e435b92..695bc5e42 100644 --- a/crates/uv-fs/src/path.rs +++ b/crates/uv-fs/src/path.rs @@ -240,16 +240,6 @@ pub fn normalize_path(path: &Path) -> PathBuf { normalized } -/// Convert a path to an absolute path, relative to the current working directory. -/// -/// Unlike [`std::fs::canonicalize`], this function does not resolve symlinks and does not require -/// the path to exist. -pub fn absolutize_path(path: &Path) -> Result, std::io::Error> { - use path_absolutize::Absolutize; - - path.absolutize_from(CWD.simplified()) -} - /// Like `fs_err::canonicalize`, but avoids attempting to resolve symlinks on Windows. pub fn canonicalize_executable(path: impl AsRef) -> std::io::Result { let path = path.as_ref(); diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 3e7378f35..e1405fc88 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -686,7 +686,7 @@ impl InterpreterInfo { /// unless the Python executable changes, so we use the executable's last modified /// time as a cache key. pub(crate) fn query_cached(executable: &Path, cache: &Cache) -> Result { - let absolute = uv_fs::absolutize_path(executable)?; + let absolute = std::path::absolute(executable)?; let cache_entry = cache.entry( CacheBucket::Interpreter, diff --git a/crates/uv-trampoline/Cargo.lock b/crates/uv-trampoline/Cargo.lock index 7dcf14ef8..a51cf1317 100644 --- a/crates/uv-trampoline/Cargo.lock +++ b/crates/uv-trampoline/Cargo.lock @@ -421,24 +421,6 @@ version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" -[[package]] -name = "path-absolutize" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" -dependencies = [ - "path-dedot", -] - -[[package]] -name = "path-dedot" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" -dependencies = [ - "once_cell", -] - [[package]] name = "path-slash" version = "0.2.1" @@ -751,7 +733,6 @@ dependencies = [ "fs-err", "fs2", "junction", - "path-absolutize", "path-slash", "tempfile", "tracing", diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index dce3ddc09..63ba222e0 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -10,7 +10,7 @@ use tracing::{debug, trace, warn}; use pep508_rs::{MarkerTree, RequirementOrigin, VerbatimUrl}; use pypi_types::{Requirement, RequirementSource}; -use uv_fs::{absolutize_path, Simplified}; +use uv_fs::Simplified; use uv_normalize::{GroupName, PackageName, DEV_DEPENDENCIES}; use uv_warnings::warn_user; @@ -88,9 +88,9 @@ impl Workspace { path: &Path, options: &DiscoveryOptions<'_>, ) -> Result { - let path = absolutize_path(path) + let path = std::path::absolute(path) .map_err(WorkspaceError::Normalize)? - .to_path_buf(); + .clone(); let project_path = path .ancestors() @@ -527,9 +527,9 @@ impl Workspace { if !seen.insert(member_root.clone()) { continue; } - let member_root = absolutize_path(&member_root) + let member_root = std::path::absolute(&member_root) .map_err(WorkspaceError::Normalize)? - .to_path_buf(); + .clone(); // If the directory is explicitly ignored, skip it. if options.ignore.contains(member_root.as_path()) { @@ -869,9 +869,9 @@ impl ProjectWorkspace { project_pyproject_toml: &PyProjectToml, options: &DiscoveryOptions<'_>, ) -> Result { - let project_path = absolutize_path(install_path) + let project_path = std::path::absolute(install_path) .map_err(WorkspaceError::Normalize)? - .to_path_buf(); + .clone(); // Check if workspaces are explicitly disabled for the project. if project_pyproject_toml @@ -1229,9 +1229,9 @@ impl VirtualProject { .and_then(|uv| uv.workspace.as_ref()) { // Otherwise, if it contains a `tool.uv.workspace` table, it's a virtual workspace. - let project_path = absolutize_path(project_root) + let project_path = std::path::absolute(project_root) .map_err(WorkspaceError::Normalize)? - .to_path_buf(); + .clone(); check_nested_workspaces(&project_path, options); diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index b60d2276e..7180d9157 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -8,7 +8,7 @@ use pep508_rs::PackageName; use tracing::{debug, warn}; use uv_cache::Cache; use uv_client::{BaseClientBuilder, Connectivity}; -use uv_fs::{absolutize_path, Simplified, CWD}; +use uv_fs::{Simplified, CWD}; use uv_python::{ EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest, VersionRequest, @@ -41,7 +41,7 @@ pub(crate) async fn init( // Default to the current directory if a path was not provided. let path = match explicit_path { None => CWD.to_path_buf(), - Some(ref path) => absolutize_path(Path::new(path))?.to_path_buf(), + Some(ref path) => std::path::absolute(path)?, }; // Make sure a project does not already exist in the given directory. diff --git a/crates/uv/src/commands/python/find.rs b/crates/uv/src/commands/python/find.rs index e17123938..3f9658b64 100644 --- a/crates/uv/src/commands/python/find.rs +++ b/crates/uv/src/commands/python/find.rs @@ -70,7 +70,7 @@ pub(crate) async fn find( println!( "{}", - uv_fs::absolutize_path(python.interpreter().sys_executable())?.simplified_display() + std::path::absolute(python.interpreter().sys_executable())?.simplified_display() ); Ok(ExitStatus::Success)