mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Remove path-absolutize
dependency (#6589)
## Summary This is now in the standard library.
This commit is contained in:
parent
7fa265a11b
commit
0dc74f619c
10 changed files with 13 additions and 66 deletions
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -2454,24 +2454,6 @@ version = "1.0.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
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]]
|
[[package]]
|
||||||
name = "path-slash"
|
name = "path-slash"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -4892,7 +4874,6 @@ dependencies = [
|
||||||
"fs-err",
|
"fs-err",
|
||||||
"fs2",
|
"fs2",
|
||||||
"junction",
|
"junction",
|
||||||
"path-absolutize",
|
|
||||||
"path-slash",
|
"path-slash",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|
|
@ -106,7 +106,6 @@ memchr = { version = "2.7.4" }
|
||||||
miette = { version = "7.2.0" }
|
miette = { version = "7.2.0" }
|
||||||
nanoid = { version = "0.4.0" }
|
nanoid = { version = "0.4.0" }
|
||||||
owo-colors = { version = "4.0.0" }
|
owo-colors = { version = "4.0.0" }
|
||||||
path-absolutize = { version = "3.1.1" }
|
|
||||||
path-slash = { version = "0.2.1" }
|
path-slash = { version = "0.2.1" }
|
||||||
pathdiff = { version = "0.2.1" }
|
pathdiff = { version = "0.2.1" }
|
||||||
petgraph = { version = "0.6.4" }
|
petgraph = { version = "0.6.4" }
|
||||||
|
|
|
@ -9,7 +9,6 @@ use distribution_filename::DistExtension;
|
||||||
use pep440_rs::VersionSpecifiers;
|
use pep440_rs::VersionSpecifiers;
|
||||||
use pep508_rs::{VerbatimUrl, VersionOrUrl};
|
use pep508_rs::{VerbatimUrl, VersionOrUrl};
|
||||||
use pypi_types::{ParsedUrlError, Requirement, RequirementSource, VerbatimParsedUrl};
|
use pypi_types::{ParsedUrlError, Requirement, RequirementSource, VerbatimParsedUrl};
|
||||||
use uv_fs::Simplified;
|
|
||||||
use uv_git::GitReference;
|
use uv_git::GitReference;
|
||||||
use uv_normalize::PackageName;
|
use uv_normalize::PackageName;
|
||||||
use uv_warnings::warn_user_once;
|
use uv_warnings::warn_user_once;
|
||||||
|
@ -250,8 +249,6 @@ pub enum LoweringError {
|
||||||
InvalidVerbatimUrl(#[from] pep508_rs::VerbatimUrlError),
|
InvalidVerbatimUrl(#[from] pep508_rs::VerbatimUrlError),
|
||||||
#[error("Can't combine URLs from both `project.dependencies` and `tool.uv.sources`")]
|
#[error("Can't combine URLs from both `project.dependencies` and `tool.uv.sources`")]
|
||||||
ConflictingUrls,
|
ConflictingUrls,
|
||||||
#[error("Could not normalize path: `{}`", _0.user_display())]
|
|
||||||
Absolutize(PathBuf, #[source] io::Error),
|
|
||||||
#[error("Fragments are not allowed in URLs: `{0}`")]
|
#[error("Fragments are not allowed in URLs: `{0}`")]
|
||||||
ForbiddenFragment(Url),
|
ForbiddenFragment(Url),
|
||||||
#[error("`workspace = false` is not yet supported")]
|
#[error("`workspace = false` is not yet supported")]
|
||||||
|
|
|
@ -22,7 +22,6 @@ either = { workspace = true }
|
||||||
encoding_rs_io = { workspace = true }
|
encoding_rs_io = { workspace = true }
|
||||||
fs-err = { workspace = true }
|
fs-err = { workspace = true }
|
||||||
fs2 = { workspace = true }
|
fs2 = { workspace = true }
|
||||||
path-absolutize = { workspace = true }
|
|
||||||
path-slash = { workspace = true }
|
path-slash = { workspace = true }
|
||||||
serde = { workspace = true, optional = true }
|
serde = { workspace = true, optional = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
|
|
|
@ -240,16 +240,6 @@ pub fn normalize_path(path: &Path) -> PathBuf {
|
||||||
normalized
|
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<Cow<Path>, std::io::Error> {
|
|
||||||
use path_absolutize::Absolutize;
|
|
||||||
|
|
||||||
path.absolutize_from(CWD.simplified())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Like `fs_err::canonicalize`, but avoids attempting to resolve symlinks on Windows.
|
/// Like `fs_err::canonicalize`, but avoids attempting to resolve symlinks on Windows.
|
||||||
pub fn canonicalize_executable(path: impl AsRef<Path>) -> std::io::Result<PathBuf> {
|
pub fn canonicalize_executable(path: impl AsRef<Path>) -> std::io::Result<PathBuf> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|
|
@ -686,7 +686,7 @@ impl InterpreterInfo {
|
||||||
/// unless the Python executable changes, so we use the executable's last modified
|
/// unless the Python executable changes, so we use the executable's last modified
|
||||||
/// time as a cache key.
|
/// time as a cache key.
|
||||||
pub(crate) fn query_cached(executable: &Path, cache: &Cache) -> Result<Self, Error> {
|
pub(crate) fn query_cached(executable: &Path, cache: &Cache) -> Result<Self, Error> {
|
||||||
let absolute = uv_fs::absolutize_path(executable)?;
|
let absolute = std::path::absolute(executable)?;
|
||||||
|
|
||||||
let cache_entry = cache.entry(
|
let cache_entry = cache.entry(
|
||||||
CacheBucket::Interpreter,
|
CacheBucket::Interpreter,
|
||||||
|
|
19
crates/uv-trampoline/Cargo.lock
generated
19
crates/uv-trampoline/Cargo.lock
generated
|
@ -421,24 +421,6 @@ version = "4.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
|
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]]
|
[[package]]
|
||||||
name = "path-slash"
|
name = "path-slash"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
|
@ -751,7 +733,6 @@ dependencies = [
|
||||||
"fs-err",
|
"fs-err",
|
||||||
"fs2",
|
"fs2",
|
||||||
"junction",
|
"junction",
|
||||||
"path-absolutize",
|
|
||||||
"path-slash",
|
"path-slash",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
|
@ -10,7 +10,7 @@ use tracing::{debug, trace, warn};
|
||||||
|
|
||||||
use pep508_rs::{MarkerTree, RequirementOrigin, VerbatimUrl};
|
use pep508_rs::{MarkerTree, RequirementOrigin, VerbatimUrl};
|
||||||
use pypi_types::{Requirement, RequirementSource};
|
use pypi_types::{Requirement, RequirementSource};
|
||||||
use uv_fs::{absolutize_path, Simplified};
|
use uv_fs::Simplified;
|
||||||
use uv_normalize::{GroupName, PackageName, DEV_DEPENDENCIES};
|
use uv_normalize::{GroupName, PackageName, DEV_DEPENDENCIES};
|
||||||
use uv_warnings::warn_user;
|
use uv_warnings::warn_user;
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ impl Workspace {
|
||||||
path: &Path,
|
path: &Path,
|
||||||
options: &DiscoveryOptions<'_>,
|
options: &DiscoveryOptions<'_>,
|
||||||
) -> Result<Workspace, WorkspaceError> {
|
) -> Result<Workspace, WorkspaceError> {
|
||||||
let path = absolutize_path(path)
|
let path = std::path::absolute(path)
|
||||||
.map_err(WorkspaceError::Normalize)?
|
.map_err(WorkspaceError::Normalize)?
|
||||||
.to_path_buf();
|
.clone();
|
||||||
|
|
||||||
let project_path = path
|
let project_path = path
|
||||||
.ancestors()
|
.ancestors()
|
||||||
|
@ -527,9 +527,9 @@ impl Workspace {
|
||||||
if !seen.insert(member_root.clone()) {
|
if !seen.insert(member_root.clone()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let member_root = absolutize_path(&member_root)
|
let member_root = std::path::absolute(&member_root)
|
||||||
.map_err(WorkspaceError::Normalize)?
|
.map_err(WorkspaceError::Normalize)?
|
||||||
.to_path_buf();
|
.clone();
|
||||||
|
|
||||||
// If the directory is explicitly ignored, skip it.
|
// If the directory is explicitly ignored, skip it.
|
||||||
if options.ignore.contains(member_root.as_path()) {
|
if options.ignore.contains(member_root.as_path()) {
|
||||||
|
@ -869,9 +869,9 @@ impl ProjectWorkspace {
|
||||||
project_pyproject_toml: &PyProjectToml,
|
project_pyproject_toml: &PyProjectToml,
|
||||||
options: &DiscoveryOptions<'_>,
|
options: &DiscoveryOptions<'_>,
|
||||||
) -> Result<Self, WorkspaceError> {
|
) -> Result<Self, WorkspaceError> {
|
||||||
let project_path = absolutize_path(install_path)
|
let project_path = std::path::absolute(install_path)
|
||||||
.map_err(WorkspaceError::Normalize)?
|
.map_err(WorkspaceError::Normalize)?
|
||||||
.to_path_buf();
|
.clone();
|
||||||
|
|
||||||
// Check if workspaces are explicitly disabled for the project.
|
// Check if workspaces are explicitly disabled for the project.
|
||||||
if project_pyproject_toml
|
if project_pyproject_toml
|
||||||
|
@ -1229,9 +1229,9 @@ impl VirtualProject {
|
||||||
.and_then(|uv| uv.workspace.as_ref())
|
.and_then(|uv| uv.workspace.as_ref())
|
||||||
{
|
{
|
||||||
// Otherwise, if it contains a `tool.uv.workspace` table, it's a virtual workspace.
|
// 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)?
|
.map_err(WorkspaceError::Normalize)?
|
||||||
.to_path_buf();
|
.clone();
|
||||||
|
|
||||||
check_nested_workspaces(&project_path, options);
|
check_nested_workspaces(&project_path, options);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use pep508_rs::PackageName;
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
use uv_cache::Cache;
|
use uv_cache::Cache;
|
||||||
use uv_client::{BaseClientBuilder, Connectivity};
|
use uv_client::{BaseClientBuilder, Connectivity};
|
||||||
use uv_fs::{absolutize_path, Simplified, CWD};
|
use uv_fs::{Simplified, CWD};
|
||||||
use uv_python::{
|
use uv_python::{
|
||||||
EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest,
|
EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest,
|
||||||
VersionRequest,
|
VersionRequest,
|
||||||
|
@ -41,7 +41,7 @@ pub(crate) async fn init(
|
||||||
// Default to the current directory if a path was not provided.
|
// Default to the current directory if a path was not provided.
|
||||||
let path = match explicit_path {
|
let path = match explicit_path {
|
||||||
None => CWD.to_path_buf(),
|
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.
|
// Make sure a project does not already exist in the given directory.
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub(crate) async fn find(
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
uv_fs::absolutize_path(python.interpreter().sys_executable())?.simplified_display()
|
std::path::absolute(python.interpreter().sys_executable())?.simplified_display()
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(ExitStatus::Success)
|
Ok(ExitStatus::Success)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue