diff --git a/crates/pep508-rs/src/lib.rs b/crates/pep508-rs/src/lib.rs index 558dbf7b9..71e793312 100644 --- a/crates/pep508-rs/src/lib.rs +++ b/crates/pep508-rs/src/lib.rs @@ -361,23 +361,6 @@ impl PyRequirement { } impl Requirement { - /// Returns `true` if the [`Version`] satisfies the [`Requirement`]. - pub fn is_satisfied_by(&self, version: &Version) -> bool { - let Some(version_or_url) = self.version_or_url.as_ref() else { - return true; - }; - - let specifiers = match version_or_url { - VersionOrUrl::VersionSpecifier(specifiers) => specifiers, - // TODO(charlie): Support URL dependencies. - VersionOrUrl::Url(_) => return false, - }; - - specifiers - .iter() - .all(|specifier| specifier.contains(version)) - } - /// Returns whether the markers apply for the given environment pub fn evaluate_markers(&self, env: &MarkerEnvironment, extras: &[ExtraName]) -> bool { if let Some(marker) = &self.marker { @@ -528,32 +511,6 @@ impl Requirement { reporter, ) } - - /// Convert a requirement with one URL type into one with another URL type. - /// - /// Example: `Requirement` to `Requirement`. - pub fn convert_url>(self) -> Requirement { - let Requirement { - name, - extras, - version_or_url, - marker, - origin, - } = self; - Requirement { - name, - extras, - version_or_url: match version_or_url { - None => None, - Some(VersionOrUrl::VersionSpecifier(specifier)) => { - Some(VersionOrUrl::VersionSpecifier(specifier)) - } - Some(VersionOrUrl::Url(url)) => Some(VersionOrUrl::Url(U::from(url))), - }, - marker, - origin, - } - } } /// A list of [`ExtraName`] that can be attached to a [`Requirement`]. diff --git a/crates/pep508-rs/src/marker.rs b/crates/pep508-rs/src/marker.rs index b3d9ba954..c576ef222 100644 --- a/crates/pep508-rs/src/marker.rs +++ b/crates/pep508-rs/src/marker.rs @@ -1602,7 +1602,7 @@ impl MarkerTree { /// the marker will be simplified to `sys_platform == 'linux'`. pub fn simplify_extras(self, extras: &[ExtraName]) -> Option { /// Returns `true` if the given expression is always `true` given the set of extras. - pub fn is_true(expression: &MarkerExpression, extras: &[ExtraName]) -> bool { + fn is_true(expression: &MarkerExpression, extras: &[ExtraName]) -> bool { match expression { MarkerExpression::Extra { operator: ExtraOperator::Equal, diff --git a/crates/pep508-rs/src/verbatim_url.rs b/crates/pep508-rs/src/verbatim_url.rs index 39cf1bfba..6547ddee0 100644 --- a/crates/pep508-rs/src/verbatim_url.rs +++ b/crates/pep508-rs/src/verbatim_url.rs @@ -155,14 +155,6 @@ impl VerbatimUrl { pub fn to_url(&self) -> Url { self.url.clone() } - - /// Create a [`VerbatimUrl`] from a [`Url`]. - /// - /// This method should be used sparingly (ideally, not at all), as it represents a loss of the - /// verbatim representation. - pub fn unknown(url: Url) -> Self { - Self { given: None, url } - } } // This impl is written out because the `derive` doesn't seem to get it right. diff --git a/crates/pypi-types/src/base_url.rs b/crates/pypi-types/src/base_url.rs index 428920743..e3249c069 100644 --- a/crates/pypi-types/src/base_url.rs +++ b/crates/pypi-types/src/base_url.rs @@ -43,12 +43,6 @@ impl BaseUrl { pub fn as_url(&self) -> &Url { &self.0 } - - /// Convert to the underlying [`Url`]. - #[must_use] - pub fn into_url(self) -> Url { - self.0 - } } impl From for BaseUrl { diff --git a/crates/pypi-types/src/parsed_url.rs b/crates/pypi-types/src/parsed_url.rs index 2da76928e..213f84039 100644 --- a/crates/pypi-types/src/parsed_url.rs +++ b/crates/pypi-types/src/parsed_url.rs @@ -5,7 +5,7 @@ use thiserror::Error; use url::{ParseError, Url}; use pep508_rs::{Pep508Url, UnnamedRequirementUrl, VerbatimUrl, VerbatimUrlError}; -use uv_git::{GitSha, GitUrl}; +use uv_git::GitUrl; use crate::{ArchiveInfo, DirInfo, DirectUrl, VcsInfo, VcsKind}; @@ -240,12 +240,6 @@ fn get_subdirectory(url: &Url) -> Option { Some(PathBuf::from(subdirectory)) } -/// Return the Git reference of the given URL, if it exists. -pub fn git_reference(url: Url) -> Result, Box> { - let ParsedGitUrl { url, .. } = ParsedGitUrl::try_from(url)?; - Ok(url.precise()) -} - impl TryFrom for ParsedUrl { type Error = ParsedUrlError; diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index 40127e044..199b66e37 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -203,12 +203,6 @@ impl RegistryClient { self.timeout } - /// Set the index URLs to use for fetching packages. - #[must_use] - pub fn with_index_url(self, index_urls: IndexUrls) -> Self { - Self { index_urls, ..self } - } - /// Fetch a package from the `PyPI` simple API. /// /// "simple" here refers to [PEP 503 – Simple Repository API](https://peps.python.org/pep-0503/) diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index 36926a142..62fb4e15e 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -2,7 +2,6 @@ //! [installer][`uv_installer`] and [build][`uv_build`] through [`BuildDispatch`] //! implementing [`BuildContext`]. -use std::ffi::OsStr; use std::ffi::OsString; use std::path::Path; @@ -90,21 +89,6 @@ impl<'a> BuildDispatch<'a> { self.options = options; self } - - /// Set the environment variables to be used when building a source distribution. - #[must_use] - pub fn with_build_extra_env_vars(mut self, sdist_build_env_variables: I) -> Self - where - I: IntoIterator, - K: AsRef, - V: AsRef, - { - self.build_extra_env_vars = sdist_build_env_variables - .into_iter() - .map(|(key, value)| (key.as_ref().to_owned(), value.as_ref().to_owned())) - .collect(); - self - } } impl<'a> BuildContext for BuildDispatch<'a> { diff --git a/crates/uv-fs/src/lib.rs b/crates/uv-fs/src/lib.rs index baf029231..c98967855 100644 --- a/crates/uv-fs/src/lib.rs +++ b/crates/uv-fs/src/lib.rs @@ -2,7 +2,6 @@ use std::fmt::Display; use std::path::{Path, PathBuf}; use fs2::FileExt; -use fs_err as fs; use tempfile::NamedTempFile; use tracing::{debug, error, trace, warn}; @@ -150,25 +149,6 @@ pub fn write_atomic_sync(path: impl AsRef, data: impl AsRef<[u8]>) -> std: Ok(()) } -/// Remove the file or directory at `path`, if it exists. -/// -/// Returns `true` if the file or directory was removed, and `false` if the path did not exist. -pub fn force_remove_all(path: impl AsRef) -> Result { - let path = path.as_ref(); - - let Some(metadata) = metadata_if_exists(path)? else { - return Ok(false); - }; - - if metadata.is_dir() { - fs::remove_dir_all(path)?; - } else { - fs::remove_file(path)?; - } - - Ok(true) -} - /// Rename a file, retrying (on Windows) if it fails due to transient operating system errors. #[cfg(feature = "tokio")] pub async fn rename_with_retry( @@ -327,14 +307,3 @@ impl Drop for LockedFile { } } } - -/// Given a path, return its metadata if the file exists, or `None` if it does not. -/// -/// If the file exists but cannot be read, returns an error. -pub fn metadata_if_exists(path: impl AsRef) -> std::io::Result> { - match fs::metadata(path) { - Ok(metadata) => Ok(Some(metadata)), - Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(None), - Err(err) => Err(err), - } -} diff --git a/crates/uv-git/src/lib.rs b/crates/uv-git/src/lib.rs index c2bc4aa0b..e4caa5ee7 100644 --- a/crates/uv-git/src/lib.rs +++ b/crates/uv-git/src/lib.rs @@ -48,11 +48,6 @@ impl GitUrl { &self.reference } - /// Returns `true` if the reference is a full commit. - pub fn is_full_commit(&self) -> bool { - matches!(self.reference, GitReference::FullCommit(_)) - } - /// Return the precise commit, if known. pub fn precise(&self) -> Option { self.precise diff --git a/crates/uv-installer/src/site_packages.rs b/crates/uv-installer/src/site_packages.rs index 8afbd299a..dfa337c2e 100644 --- a/crates/uv-installer/src/site_packages.rs +++ b/crates/uv-installer/src/site_packages.rs @@ -151,36 +151,6 @@ impl SitePackages { .collect() } - /// Returns the editable distribution installed from the given URL, if any. - pub fn get_editables(&self, url: &Url) -> Vec<&InstalledDist> { - let Some(indexes) = self.by_url.get(url) else { - return Vec::new(); - }; - indexes - .iter() - .flat_map(|&index| &self.distributions[index]) - .filter(|dist| dist.is_editable()) - .collect() - } - - /// Remove the editable distribution installed from the given URL, if any. - pub fn remove_editables(&mut self, url: &Url) -> Vec { - let Some(indexes) = self.by_url.get(url) else { - return Vec::new(); - }; - indexes - .iter() - .filter_map(|index| { - let dist = &mut self.distributions[*index]; - if dist.as_ref().is_some_and(InstalledDist::is_editable) { - std::mem::take(dist) - } else { - None - } - }) - .collect() - } - /// Returns `true` if there are any installed packages. pub fn any(&self) -> bool { self.distributions.iter().any(Option::is_some) @@ -501,8 +471,4 @@ impl InstalledPackagesProvider for SitePackages { fn get_packages(&self, name: &PackageName) -> Vec<&InstalledDist> { self.get_packages(name) } - - fn get_editables(&self, url: &Url) -> Vec<&InstalledDist> { - self.get_editables(url) - } } diff --git a/crates/uv-resolver/src/resolution/graph.rs b/crates/uv-resolver/src/resolution/graph.rs index 7041bc8cd..7731d7854 100644 --- a/crates/uv-resolver/src/resolution/graph.rs +++ b/crates/uv-resolver/src/resolution/graph.rs @@ -7,8 +7,7 @@ use pubgrub::type_aliases::SelectedDependencies; use rustc_hash::{FxHashMap, FxHashSet}; use distribution_types::{ - Dist, DistributionMetadata, Name, Requirement, ResolutionDiagnostic, ResolvedDist, VersionId, - VersionOrUrlRef, + Dist, DistributionMetadata, Name, Requirement, ResolutionDiagnostic, VersionId, VersionOrUrlRef, }; use pep440_rs::{Version, VersionSpecifier}; use pep508_rs::MarkerEnvironment; @@ -366,15 +365,6 @@ impl ResolutionGraph { .any(|index| self.petgraph[index].name() == name) } - /// Iterate over the [`ResolvedDist`] entities in this resolution. - pub fn into_distributions(self) -> impl Iterator { - self.petgraph - .into_nodes_edges() - .0 - .into_iter() - .map(|node| node.weight.dist) - } - /// Return the [`ResolutionDiagnostic`]s that were encountered while building the graph. pub fn diagnostics(&self) -> &[ResolutionDiagnostic] { &self.diagnostics diff --git a/crates/uv-types/src/traits.rs b/crates/uv-types/src/traits.rs index 2f5e91136..1d3249c3d 100644 --- a/crates/uv-types/src/traits.rs +++ b/crates/uv-types/src/traits.rs @@ -2,7 +2,6 @@ use std::future::Future; use std::path::{Path, PathBuf}; use anyhow::Result; -use url::Url; use distribution_types::{ CachedDist, IndexLocations, InstalledDist, Requirement, Resolution, SourceDist, @@ -134,7 +133,6 @@ pub trait SourceBuildTrait { pub trait InstalledPackagesProvider: Clone + Send + Sync + 'static { fn iter(&self) -> impl Iterator; fn get_packages(&self, name: &PackageName) -> Vec<&InstalledDist>; - fn get_editables(&self, url: &Url) -> Vec<&InstalledDist>; } /// An [`InstalledPackagesProvider`] with no packages in it. @@ -149,8 +147,4 @@ impl InstalledPackagesProvider for EmptyInstalledPackages { fn iter(&self) -> impl Iterator { std::iter::empty() } - - fn get_editables(&self, _url: &Url) -> Vec<&InstalledDist> { - Vec::new() - } }