mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Bump MSRV to 1.84 (#12670)
## Summary Closes https://github.com/astral-sh/uv/issues/12649.
This commit is contained in:
parent
420fc287fa
commit
42dcea0ee2
64 changed files with 162 additions and 144 deletions
|
@ -12,7 +12,7 @@ resolver = "2"
|
|||
|
||||
[workspace.package]
|
||||
edition = "2021"
|
||||
rust-version = "1.83"
|
||||
rust-version = "1.84"
|
||||
homepage = "https://pypi.org/project/uv/"
|
||||
documentation = "https://pypi.org/project/uv/"
|
||||
repository = "https://github.com/astral-sh/uv"
|
||||
|
|
|
@ -131,7 +131,7 @@ impl Credentials {
|
|||
// Ensure the username matches if provided
|
||||
if username.is_some_and(|username| username != entry.login) {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
Some(Credentials::Basic {
|
||||
username: Username::new(Some(entry.login.clone())),
|
||||
|
|
|
@ -361,7 +361,7 @@ impl AuthMiddleware {
|
|||
{
|
||||
trace!("Updating cached credentials for {url} to {credentials:?}");
|
||||
self.cache().insert(&url, credentials);
|
||||
};
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ impl AuthMiddleware {
|
|||
trace!("Using credentials from previous fetch for {url}");
|
||||
} else {
|
||||
trace!("Skipping fetch of credentials for {url}, previous attempt failed");
|
||||
};
|
||||
}
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
@ -513,14 +513,14 @@ fn tracing_url(request: &Request, credentials: Option<&Credentials>) -> String {
|
|||
.and_then(|credentials| credentials.username())
|
||||
{
|
||||
let _ = url.set_username(username);
|
||||
};
|
||||
}
|
||||
if credentials
|
||||
.as_ref()
|
||||
.and_then(|credentials| credentials.password())
|
||||
.is_some()
|
||||
{
|
||||
let _ = url.set_password(Some("****"));
|
||||
};
|
||||
}
|
||||
url.to_string()
|
||||
} else {
|
||||
request.url().to_string()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::collections::{BTreeMap, Bound};
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -603,7 +604,7 @@ impl PyProjectToml {
|
|||
return Err(ValidationError::InvalidGroup(group.to_string()));
|
||||
}
|
||||
|
||||
writer.push_str(&format!("[{group}]\n"));
|
||||
let _ = writeln!(writer, "[{group}]");
|
||||
for (name, object_reference) in entries {
|
||||
// More strict than the spec, we enforce the recommendation
|
||||
if !name
|
||||
|
@ -614,7 +615,7 @@ impl PyProjectToml {
|
|||
}
|
||||
|
||||
// TODO(konsti): Validate that the object references are valid Python identifiers.
|
||||
writer.push_str(&format!("{name} = {object_reference}\n"));
|
||||
let _ = writeln!(writer, "{name} = {object_reference}");
|
||||
}
|
||||
writer.push('\n');
|
||||
Ok(())
|
||||
|
@ -963,7 +964,7 @@ mod tests {
|
|||
fn format_err(err: impl std::error::Error) -> String {
|
||||
let mut formatted = err.to_string();
|
||||
for source in iter::successors(err.source(), |&err| err.source()) {
|
||||
formatted += &format!("\n Caused by: {source}");
|
||||
let _ = write!(formatted, "\n Caused by: {source}");
|
||||
}
|
||||
formatted
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ fn write_source_dist(
|
|||
if !include_matcher.match_path(relative) || exclude_matcher.is_match(relative) {
|
||||
trace!("Excluding: `{}`", relative.user_display());
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
debug!("Including {}", relative.user_display());
|
||||
if entry.file_type().is_dir() {
|
||||
|
|
|
@ -560,7 +560,7 @@ fn wheel_subdir_from_globs(
|
|||
if !matcher.match_path(relative) {
|
||||
trace!("Excluding {}: `{}`", globs_field, relative.user_display());
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
let relative_licenses = Path::new(target)
|
||||
.join(relative)
|
||||
|
|
|
@ -568,7 +568,7 @@ impl SourceBuild {
|
|||
nor `setup.cfg` are present in the directory",
|
||||
source_tree.simplified_display().cyan(),
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
default_backend.clone()
|
||||
};
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
use std::error::Error;
|
||||
use std::fmt::Debug;
|
||||
use std::fmt::Write;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::{env, iter};
|
||||
|
||||
use itertools::Itertools;
|
||||
use reqwest::{Client, ClientBuilder, Proxy, Response};
|
||||
use reqwest_middleware::{ClientWithMiddleware, Middleware};
|
||||
|
@ -5,14 +13,9 @@ use reqwest_retry::policies::ExponentialBackoff;
|
|||
use reqwest_retry::{
|
||||
DefaultRetryableStrategy, RetryTransientMiddleware, Retryable, RetryableStrategy,
|
||||
};
|
||||
use std::error::Error;
|
||||
use std::fmt::Debug;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::{env, iter};
|
||||
use tracing::{debug, trace};
|
||||
use url::Url;
|
||||
|
||||
use uv_auth::{AuthMiddleware, UrlAuthPolicies};
|
||||
use uv_configuration::{KeyringProviderType, TrustedHost};
|
||||
use uv_fs::Simplified;
|
||||
|
@ -186,7 +189,7 @@ impl<'a> BaseClientBuilder<'a> {
|
|||
if let Some(markers) = self.markers {
|
||||
let linehaul = LineHaul::new(markers, self.platform);
|
||||
if let Ok(output) = serde_json::to_string(&linehaul) {
|
||||
user_agent_string += &format!(" {output}");
|
||||
let _ = write!(user_agent_string, " {output}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ impl SimpleHtml {
|
|||
// the final path component of the URL.
|
||||
let filename = path
|
||||
.split('/')
|
||||
.last()
|
||||
.next_back()
|
||||
.ok_or_else(|| Error::MissingFilename(href.to_string()))?;
|
||||
|
||||
// Strip any query string from the filename.
|
||||
|
|
|
@ -415,9 +415,8 @@ impl<'b, B: 'b + ?Sized + AsRef<[u8]>, I: Iterator<Item = &'b B>> Iterator
|
|||
self.skip_whitespace();
|
||||
self.maybe_parse_directive_delimiter();
|
||||
let directive = CacheControlDirective { name, value };
|
||||
match self.emit_directive(directive) {
|
||||
None => continue,
|
||||
Some(d) => return Some(d),
|
||||
if let Some(d) = self.emit_directive(directive) {
|
||||
return Some(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -912,7 +912,7 @@ impl RegistryClient {
|
|||
return Err(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Create a request to stream the file.
|
||||
|
|
|
@ -43,7 +43,7 @@ pub fn confirm(message: &str, term: &Term, default: bool) -> std::io::Result<boo
|
|||
});
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let report = format!(
|
||||
|
|
|
@ -113,6 +113,7 @@ fn generate() -> String {
|
|||
output
|
||||
}
|
||||
|
||||
#[allow(clippy::format_push_string)]
|
||||
fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut Vec<&'a Command>) {
|
||||
if command.is_hide_set() && !SHOW_HIDDEN_COMMANDS.contains(&command.get_name()) {
|
||||
return;
|
||||
|
@ -137,7 +138,7 @@ fn generate_command<'a>(output: &mut String, command: &'a Command, parents: &mut
|
|||
if let Some(about) = command.get_long_about().or_else(|| command.get_about()) {
|
||||
output.push_str(&about.to_string());
|
||||
output.push_str("\n\n");
|
||||
};
|
||||
}
|
||||
|
||||
// Display the usage
|
||||
{
|
||||
|
|
|
@ -204,6 +204,7 @@ impl Set {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::format_push_string)]
|
||||
fn emit_field(output: &mut String, name: &str, field: &OptionField, parents: &[Set]) {
|
||||
let header_level = if parents.len() > 1 { "####" } else { "###" };
|
||||
let parents_anchor = parents.iter().filter_map(|parent| parent.name()).join("_");
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> Iterator for MemchrSplitter<'a> {
|
|||
let min = usize::from(self.offset < self.haystack.len());
|
||||
|
||||
// Maximum possible splits is remaining length divided by 2 (minimum one char between delimiters).
|
||||
let max = (self.haystack.len() - self.offset + 1) / 2 + min;
|
||||
let max = (self.haystack.len() - self.offset).div_ceil(2) + min;
|
||||
|
||||
(min, Some(max))
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ impl WheelFilename {
|
|||
// Determine whether any of the tag types contain a period, which would indicate
|
||||
// that at least one of the tag types includes multiple tags (which in turn
|
||||
// necessitates taking the slow path).
|
||||
memchr(b'.', stem[build_tag_or_python_tag..].as_bytes()).is_none(),
|
||||
memchr(b'.', &stem.as_bytes()[build_tag_or_python_tag..]).is_none(),
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -312,7 +312,7 @@ impl TryFrom<&Url> for WheelFilename {
|
|||
"URL must have a path".to_string(),
|
||||
)
|
||||
})?
|
||||
.last()
|
||||
.next_back()
|
||||
.ok_or_else(|| {
|
||||
WheelFilenameError::InvalidWheelFileName(
|
||||
url.to_string(),
|
||||
|
|
|
@ -202,7 +202,7 @@ impl InstalledDist {
|
|||
path: path.to_path_buf().into_boxed_path(),
|
||||
})));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if metadata.is_dir() {
|
||||
let Some(egg_metadata) = read_metadata(&path.join("PKG-INFO")) else {
|
||||
|
|
|
@ -942,12 +942,14 @@ impl RemoteSource for File {
|
|||
impl RemoteSource for Url {
|
||||
fn filename(&self) -> Result<Cow<'_, str>, Error> {
|
||||
// Identify the last segment of the URL as the filename.
|
||||
let path_segments = self
|
||||
let mut path_segments = self
|
||||
.path_segments()
|
||||
.ok_or_else(|| Error::MissingPathSegments(self.to_string()))?;
|
||||
|
||||
// This is guaranteed by the contract of `Url::path_segments`.
|
||||
let last = path_segments.last().expect("path segments is non-empty");
|
||||
let last = path_segments
|
||||
.next_back()
|
||||
.expect("path segments is non-empty");
|
||||
|
||||
// Decode the filename, which may be percent-encoded.
|
||||
let filename = percent_encoding::percent_decode_str(last).decode_utf8()?;
|
||||
|
@ -966,7 +968,7 @@ impl RemoteSource for UrlString {
|
|||
let last = self
|
||||
.base_str()
|
||||
.split('/')
|
||||
.last()
|
||||
.next_back()
|
||||
.ok_or_else(|| Error::MissingPathSegments(self.to_string()))?;
|
||||
|
||||
// Decode the filename, which may be percent-encoded.
|
||||
|
|
|
@ -838,8 +838,8 @@ impl TryFrom<RequirementSourceWire> for RequirementSource {
|
|||
"subdirectory" => {
|
||||
subdirectory = Some(PortablePathBuf::from(val.as_ref()));
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
let precise = repository.fragment().map(GitOid::from_str).transpose()?;
|
||||
|
|
|
@ -497,12 +497,14 @@ mod test {
|
|||
}
|
||||
|
||||
async fn format_err(input: &str) -> String {
|
||||
use std::fmt::Write;
|
||||
|
||||
let err = requires_dist_from_pyproject_toml(input).await.unwrap_err();
|
||||
let mut causes = err.chain();
|
||||
let mut message = String::new();
|
||||
message.push_str(&format!("error: {}\n", causes.next().unwrap()));
|
||||
let _ = writeln!(message, "error: {}", causes.next().unwrap());
|
||||
for err in causes {
|
||||
message.push_str(&format!(" Caused by: {err}\n"));
|
||||
let _ = writeln!(message, " Caused by: {err}");
|
||||
}
|
||||
message
|
||||
}
|
||||
|
|
|
@ -2420,8 +2420,6 @@ pub fn prune(cache: &Cache) -> Result<Removal, Error> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we find a `revision.rev` file, read the pointer, and remove any extraneous
|
||||
|
@ -2445,8 +2443,6 @@ pub fn prune(cache: &Cache) -> Result<Removal, Error> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn is_same_file_allow_missing(left: &Path, right: &Path) -> Option<bool> {
|
|||
// Second, check the files directly.
|
||||
if let Ok(value) = same_file::is_same_file(left, right) {
|
||||
return Some(value);
|
||||
};
|
||||
}
|
||||
|
||||
// Often, one of the directories won't exist yet so perform the comparison up a level.
|
||||
if let (Some(left_parent), Some(right_parent), Some(left_name), Some(right_name)) = (
|
||||
|
@ -38,7 +38,7 @@ pub fn is_same_file_allow_missing(left: &Path, right: &Path) -> Option<bool> {
|
|||
Ok(false) => return Some(false),
|
||||
_ => (),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// We couldn't determine if they're the same.
|
||||
None
|
||||
|
@ -106,7 +106,7 @@ pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io:
|
|||
},
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(err) => return Err(err),
|
||||
};
|
||||
}
|
||||
|
||||
// Replace it with a new symlink.
|
||||
junction::create(
|
||||
|
@ -411,7 +411,7 @@ pub async fn persist_with_retry(
|
|||
to.display(),
|
||||
error_message,
|
||||
);
|
||||
};
|
||||
}
|
||||
})
|
||||
.await;
|
||||
|
||||
|
@ -485,7 +485,7 @@ pub fn persist_with_retry_sync(
|
|||
to.display(),
|
||||
error_message,
|
||||
);
|
||||
};
|
||||
}
|
||||
})
|
||||
.call();
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ fn normalized(path: &Path) -> PathBuf {
|
|||
normalized.push(component);
|
||||
}
|
||||
Component::ParentDir => {
|
||||
match normalized.components().last() {
|
||||
match normalized.components().next_back() {
|
||||
None | Some(Component::ParentDir | Component::RootDir) => {
|
||||
// Preserve leading and above-root `..`
|
||||
normalized.push(component);
|
||||
|
@ -331,7 +331,7 @@ pub fn relative_to(
|
|||
|
||||
// go as many levels up as required
|
||||
let levels_up = base.components().count() - common_prefix.components().count();
|
||||
let up = std::iter::repeat("..").take(levels_up).collect::<PathBuf>();
|
||||
let up = std::iter::repeat_n("..", levels_up).collect::<PathBuf>();
|
||||
|
||||
Ok(up.join(stripped))
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ impl<'a> GitHubRepository<'a> {
|
|||
// The fast path is only available for GitHub repositories.
|
||||
if url.host_str() != Some("github.com") {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
// The GitHub URL must take the form: `https://github.com/{user}/{repo}`, e.g.,
|
||||
// `https://github.com/astral-sh/uv`.
|
||||
|
|
|
@ -56,7 +56,7 @@ fn main() {
|
|||
if !include_matcher.match_path(&relative) || exclude_matcher.is_match(&relative) {
|
||||
trace!("Excluding: `{}`", relative.display());
|
||||
continue;
|
||||
};
|
||||
}
|
||||
println!("{}", relative.display());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ impl<'a> Planner<'a> {
|
|||
}
|
||||
if entry.dist.filename.version != sdist.version {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
if entry.built && no_build {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ pub fn find_archive_dist_info<'a, T: Copy>(
|
|||
dist_info_prefix.to_string(),
|
||||
filename.name.to_string(),
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
Ok((payload, dist_info_prefix))
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ pub fn is_metadata_entry(path: &str, filename: &WheelFilename) -> Result<bool, E
|
|||
dist_info_prefix.to_string(),
|
||||
filename.name.to_string(),
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ pub fn find_flat_dist_info(
|
|||
dist_info_prefix.to_string(),
|
||||
filename.name.to_string(),
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
Ok(dist_info_prefix)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<K: Eq + Hash, V: Clone, H: BuildHasher + Clone> OnceMap<K, V, H> {
|
|||
// Make sure the value wasn't inserted in-between us checking the map and registering the waiter.
|
||||
if let Value::Filled(value) = self.items.get(key).expect("map is append-only").value() {
|
||||
return Some(value.clone());
|
||||
};
|
||||
}
|
||||
|
||||
// Wait until the value is inserted.
|
||||
notification.await;
|
||||
|
|
|
@ -635,7 +635,7 @@ fn parse_extras_cursor<T: Pep508Url>(
|
|||
});
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
// wsp* after the identifier
|
||||
cursor.eat_whitespace();
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ fn parse_marker_operator<T: Pep508Url>(
|
|||
input: cursor.to_string(),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
cursor.eat_whitespace();
|
||||
cursor.next_expect_char('i', cursor.pos())?;
|
||||
cursor.next_expect_char('n', cursor.pos())?;
|
||||
|
@ -607,7 +607,7 @@ pub(crate) fn parse_markers_cursor<T: Pep508Url>(
|
|||
len: cursor.remaining(),
|
||||
input: cursor.to_string(),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Ok(marker)
|
||||
}
|
||||
|
|
|
@ -931,14 +931,14 @@ impl MarkerTree {
|
|||
MarkerWarningKind::LexicographicComparison,
|
||||
format!("Comparing {l_string} and {value} lexicographically"),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
if let Bound::Included(value) | Bound::Excluded(value) = end {
|
||||
reporter.report(
|
||||
MarkerWarningKind::LexicographicComparison,
|
||||
format!("Comparing {l_string} and {value} lexicographically"),
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
//! Vendored from <https://github.com/PyO3/python-pkginfo-rs>
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Write;
|
||||
use std::str;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::metadata::Headers;
|
||||
use crate::MetadataError;
|
||||
use std::fmt::Display;
|
||||
use std::str;
|
||||
use std::str::FromStr;
|
||||
|
||||
/// Code Metadata 2.3 as specified in
|
||||
/// <https://packaging.python.org/specifications/core-metadata/>.
|
||||
|
@ -200,15 +202,15 @@ impl Metadata23 {
|
|||
let value = value.to_string();
|
||||
let mut lines = value.lines();
|
||||
if let Some(line) = lines.next() {
|
||||
writer.push_str(&format!("{key}: {line}\n"));
|
||||
let _ = writeln!(writer, "{key}: {line}");
|
||||
} else {
|
||||
// The value is an empty string
|
||||
writer.push_str(&format!("{key}: \n"));
|
||||
let _ = writeln!(writer, "{key}: ");
|
||||
}
|
||||
for line in lines {
|
||||
// Python implementations vary
|
||||
// https://github.com/pypa/pyproject-metadata/pull/150/files#diff-7d938dbc255a08c2cfab1b4f1f8d1f6519c9312dd0a39d7793fa778474f1fbd1L135-R141
|
||||
writer.push_str(&format!("{}{}\n", " ".repeat(key.len() + 2), line));
|
||||
let _ = writeln!(writer, "{}{}", " ".repeat(key.len() + 2), line);
|
||||
}
|
||||
}
|
||||
fn write_opt_str(writer: &mut String, key: &str, value: Option<&impl Display>) {
|
||||
|
|
|
@ -978,7 +978,7 @@ pub fn find_python_installations<'a>(
|
|||
PythonRequest::Version(version) => {
|
||||
if let Err(err) = version.check_supported() {
|
||||
return Box::new(iter::once(Err(Error::InvalidVersionRequest(err))));
|
||||
};
|
||||
}
|
||||
Box::new({
|
||||
debug!("Searching for {request} in {sources}");
|
||||
python_interpreters(version, None, environments, preference, cache)
|
||||
|
@ -1004,7 +1004,7 @@ pub fn find_python_installations<'a>(
|
|||
PythonRequest::ImplementationVersion(implementation, version) => {
|
||||
if let Err(err) = version.check_supported() {
|
||||
return Box::new(iter::once(Err(Error::InvalidVersionRequest(err))));
|
||||
};
|
||||
}
|
||||
Box::new({
|
||||
debug!("Searching for {request} in {sources}");
|
||||
python_interpreters(
|
||||
|
@ -1026,8 +1026,8 @@ pub fn find_python_installations<'a>(
|
|||
if let Some(version) = request.version() {
|
||||
if let Err(err) = version.check_supported() {
|
||||
return Box::new(iter::once(Err(Error::InvalidVersionRequest(err))));
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
Box::new({
|
||||
debug!("Searching for {request} in {sources}");
|
||||
python_interpreters(
|
||||
|
|
|
@ -555,7 +555,7 @@ impl ManagedPythonDownload {
|
|||
return Ok(DownloadResult::AlreadyAvailable(path));
|
||||
}
|
||||
|
||||
let filename = url.path_segments().unwrap().last().unwrap();
|
||||
let filename = url.path_segments().unwrap().next_back().unwrap();
|
||||
let ext = SourceDistExtension::from_path(filename)
|
||||
.map_err(|err| Error::MissingExtension(url.to_string(), err))?;
|
||||
let (reader, size) = read_url(&url, client).await?;
|
||||
|
@ -593,7 +593,7 @@ impl ManagedPythonDownload {
|
|||
.await
|
||||
.map_err(|err| Error::ExtractError(filename.to_string(), err))?;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
hasher.finish().await.map_err(Error::HashExhaustion)?;
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ impl PythonEnvironment {
|
|||
}));
|
||||
}
|
||||
Err(err) => return Err(Error::Discovery(err.into())),
|
||||
};
|
||||
}
|
||||
|
||||
if root.as_ref().is_file() {
|
||||
return Err(InvalidEnvironment {
|
||||
|
@ -211,7 +211,7 @@ impl PythonEnvironment {
|
|||
kind: InvalidEnvironmentKind::MissingExecutable(executable.clone()),
|
||||
}
|
||||
.into());
|
||||
};
|
||||
}
|
||||
|
||||
let interpreter = Interpreter::query(executable, cache)?;
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ mod tests {
|
|||
match self.search_path.as_mut() {
|
||||
Some(paths) => paths.push(path),
|
||||
None => self.search_path = Some(vec![path]),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new directory and add it to the search path.
|
||||
|
|
|
@ -496,7 +496,7 @@ impl ManagedPythonInstallation {
|
|||
err,
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -224,7 +224,7 @@ fn find_sysconfigdata(
|
|||
let metadata = entry.metadata()?;
|
||||
if metadata.is_symlink() {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
if metadata.is_file() {
|
||||
return Ok(entry.path());
|
||||
|
|
|
@ -111,7 +111,7 @@ pub(crate) fn conda_environment_from_env(kind: CondaEnvironmentKind) -> Option<P
|
|||
|
||||
if kind != CondaEnvironmentKind::from_prefix_path(&path) {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
Some(path)
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ pub fn remove_registry_entry<'a>(
|
|||
.context("Failed to clear registry entries under HKCU:\\{python_entry}"),
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,6 +284,6 @@ pub fn remove_orphan_registry_entries(installations: &[ManagedPythonInstallation
|
|||
if let Err(err) = CURRENT_USER.remove_tree(&python_entry) {
|
||||
// TODO(konsti): We don't have an installation key here.
|
||||
warn_user_once!("Failed to remove orphan registry key HKCU:\\{python_entry}: {err}");
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ impl CandidateSelector {
|
|||
}
|
||||
if !range.contains(version) {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
let Some(dist) = maybe_dist.prioritized_dist() else {
|
||||
continue;
|
||||
};
|
||||
|
|
|
@ -1459,7 +1459,7 @@ impl Lock {
|
|||
return Ok(SatisfiesResult::MissingLocalIndex(name, version, path));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// If the package is immutable, we don't need to validate it (or its dependencies).
|
||||
|
@ -2257,7 +2257,7 @@ impl Package {
|
|||
}
|
||||
.into()),
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(sdist) = self.to_source_dist(workspace_root)? {
|
||||
|
@ -3599,8 +3599,8 @@ impl GitSource {
|
|||
"branch" => kind = GitSourceKind::Branch(val.into_owned()),
|
||||
"rev" => kind = GitSourceKind::Rev(val.into_owned()),
|
||||
"subdirectory" => subdirectory = Some(PortablePathBuf::from(val.as_ref()).into()),
|
||||
_ => continue,
|
||||
};
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let precise = GitOid::from_str(url.fragment().ok_or(GitSourceError::MissingSha)?)
|
||||
.map_err(|_| GitSourceError::InvalidSha)?;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::collections::{BTreeSet, VecDeque};
|
||||
use std::fmt::Write;
|
||||
|
||||
use either::Either;
|
||||
use itertools::Itertools;
|
||||
|
@ -431,17 +432,17 @@ impl<'env> TreeDisplay<'env> {
|
|||
if let Some(version) = package_id.version.as_ref() {
|
||||
line.push(' ');
|
||||
line.push('v');
|
||||
line.push_str(&format!("{version}"));
|
||||
let _ = write!(line, "{version}");
|
||||
}
|
||||
|
||||
if let Some(edge) = edge {
|
||||
match edge {
|
||||
Edge::Prod(_) => {}
|
||||
Edge::Optional(extra, _) => {
|
||||
line.push_str(&format!(" (extra: {extra})"));
|
||||
let _ = write!(line, " (extra: {extra})");
|
||||
}
|
||||
Edge::Dev(group, _) => {
|
||||
line.push_str(&format!(" (group: {group})"));
|
||||
let _ = write!(line, " (group: {group})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ impl PubGrubPriorities {
|
|||
if matches!(entry.get(), PubGrubPriority::ConflictEarly(_)) {
|
||||
// Already in the right category
|
||||
return false;
|
||||
};
|
||||
}
|
||||
let index = Self::get_index(&entry).unwrap_or(len);
|
||||
entry.insert(PubGrubPriority::ConflictEarly(Reverse(index)));
|
||||
true
|
||||
|
@ -225,7 +225,7 @@ impl PubGrubPriorities {
|
|||
) {
|
||||
// Already in the right category
|
||||
return false;
|
||||
};
|
||||
}
|
||||
let index = Self::get_index(&entry).unwrap_or(len);
|
||||
entry.insert(PubGrubPriority::ConflictLate(Reverse(index)));
|
||||
true
|
||||
|
|
|
@ -711,7 +711,7 @@ impl PubGrubReportFormatter<'_> {
|
|||
output_hints,
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a [`PubGrubHint`] for a package that doesn't have any wheels matching the current
|
||||
|
@ -1957,7 +1957,7 @@ impl std::fmt::Display for PackageRange<'_> {
|
|||
(Bound::Excluded(v), Bound::Unbounded) => write!(f, "{package}>{v}")?,
|
||||
(Bound::Excluded(v), Bound::Included(b)) => write!(f, "{package}>{v},<={b}")?,
|
||||
(Bound::Excluded(v), Bound::Excluded(b)) => write!(f, "{package}>{v},<{b}")?,
|
||||
};
|
||||
}
|
||||
}
|
||||
if segments.len() > 1 {
|
||||
writeln!(f)?;
|
||||
|
@ -2015,7 +2015,7 @@ impl std::fmt::Display for DependsOn<'_> {
|
|||
write!(f, "depend on ")?;
|
||||
} else {
|
||||
write!(f, "depends on ")?;
|
||||
};
|
||||
}
|
||||
|
||||
match self.dependency2 {
|
||||
Some(ref dependency2) => write!(
|
||||
|
|
|
@ -1363,7 +1363,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
// packages that include a source distribution), we don't need to fork.
|
||||
if dist.implied_markers().is_true() {
|
||||
return Ok(None);
|
||||
};
|
||||
}
|
||||
|
||||
// If the user explicitly marked a platform as required, ensure it has coverage.
|
||||
for marker in self.options.required_environments.iter().copied() {
|
||||
|
@ -2813,7 +2813,7 @@ impl ForkState {
|
|||
.partial_solution
|
||||
.add_decision(self.next, version);
|
||||
return;
|
||||
};
|
||||
}
|
||||
self.pubgrub
|
||||
.add_incompatibility(Incompatibility::custom_version(
|
||||
self.next,
|
||||
|
|
|
@ -68,7 +68,7 @@ impl Urls {
|
|||
debug!("Allowing an editable variant of {}", &package_url.verbatim);
|
||||
*editable = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
package_urls.push(url);
|
||||
|
|
|
@ -605,7 +605,7 @@ fn copy_launcher_windows(
|
|||
Err(err) => {
|
||||
return Err(err.into());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -830,10 +830,10 @@ impl TryFrom<SourcesWire> for Sources {
|
|||
for (lhs, rhs) in sources.iter().zip(sources.iter().skip(1)) {
|
||||
if lhs.extra() != rhs.extra() {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
if lhs.group() != rhs.group() {
|
||||
continue;
|
||||
};
|
||||
}
|
||||
|
||||
let lhs = lhs.marker();
|
||||
let rhs = rhs.marker();
|
||||
|
@ -1070,7 +1070,7 @@ impl<'de> Deserialize<'de> for Source {
|
|||
"expected at most one of `rev`, `tag`, or `branch`",
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// If the user prefixed the URL with `git+`, strip it.
|
||||
let git = if let Some(git) = git.as_str().strip_prefix("git+") {
|
||||
|
|
|
@ -1121,7 +1121,7 @@ pub fn add_dependency(
|
|||
decor.set_prefix(targeted_decor.prefix().unwrap().clone());
|
||||
targeted_decor.set_prefix(""); // Re-formatted later by `reformat_array_multiline`
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
deps.insert_formatted(index, value);
|
||||
|
||||
|
|
|
@ -553,12 +553,12 @@ impl Workspace {
|
|||
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
let path = PathBuf::from(value);
|
||||
if path.is_absolute() {
|
||||
return Some(path);
|
||||
};
|
||||
}
|
||||
|
||||
// Resolve the path relative to the install path.
|
||||
Some(workspace.install_path.join(path))
|
||||
|
@ -570,12 +570,12 @@ impl Workspace {
|
|||
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
let path = PathBuf::from(value);
|
||||
if path.is_absolute() {
|
||||
return Some(path);
|
||||
};
|
||||
}
|
||||
|
||||
// Resolve the path relative to current directory.
|
||||
// Note this differs from `UV_PROJECT_ENVIRONMENT`
|
||||
|
|
|
@ -379,17 +379,23 @@ impl<'env> DisplayDependencyGraph<'env> {
|
|||
if self.invert {
|
||||
let parent = self.graph.edge_endpoints(edge).unwrap().0;
|
||||
let parent = &self.graph[parent].name;
|
||||
let version = match source.version_or_url.as_ref() {
|
||||
None => "*".to_string(),
|
||||
Some(version) => version.to_string(),
|
||||
};
|
||||
line.push_str(&format!("[requires: {parent} {version}]"));
|
||||
match source.version_or_url.as_ref() {
|
||||
None => {
|
||||
let _ = write!(line, "[requires: {parent} *]");
|
||||
}
|
||||
Some(version) => {
|
||||
let _ = write!(line, "[requires: {parent} {version}]");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let version = match source.version_or_url.as_ref() {
|
||||
None => "*".to_string(),
|
||||
Some(version) => version.to_string(),
|
||||
};
|
||||
line.push_str(&format!("[required: {version}]"));
|
||||
match source.version_or_url.as_ref() {
|
||||
None => {
|
||||
let _ = write!(line, "[required: *]");
|
||||
}
|
||||
Some(version) => {
|
||||
let _ = write!(line, "[required: {version}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -506,7 +506,7 @@ pub(crate) async fn add(
|
|||
|
||||
// Redact the credentials.
|
||||
redact_credentials(&mut git);
|
||||
};
|
||||
}
|
||||
Some(Source::Git {
|
||||
git,
|
||||
subdirectory,
|
||||
|
|
|
@ -866,7 +866,7 @@ impl InitProjectKind {
|
|||
// Generate `src` files
|
||||
if !bare {
|
||||
generate_package_scripts(name, path, build_backend, true)?;
|
||||
};
|
||||
}
|
||||
|
||||
// Initialize the version control system.
|
||||
init_vcs(path, vcs)?;
|
||||
|
@ -1136,7 +1136,7 @@ fn generate_package_scripts(
|
|||
let pyi_file = pkg_dir.join("_core.pyi");
|
||||
if !pyi_file.try_exists()? {
|
||||
fs_err::write(pyi_file, pyi_contents)?;
|
||||
};
|
||||
}
|
||||
// Return python script calling binary
|
||||
binary_call_script
|
||||
}
|
||||
|
@ -1167,7 +1167,7 @@ fn generate_package_scripts(
|
|||
let pyi_file = pkg_dir.join("_core.pyi");
|
||||
if !pyi_file.try_exists()? {
|
||||
fs_err::write(pyi_file, pyi_contents)?;
|
||||
};
|
||||
}
|
||||
// Return python script calling binary
|
||||
binary_call_script
|
||||
}
|
||||
|
|
|
@ -340,7 +340,11 @@ impl std::fmt::Display for ConflictError {
|
|||
}
|
||||
ConflictPackage::Group(ref group) => format!("group `{group}`"),
|
||||
};
|
||||
(i == 0).then(|| capitalize(&conflict)).unwrap_or(conflict)
|
||||
if i == 0 {
|
||||
capitalize(&conflict)
|
||||
} else {
|
||||
conflict
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
)
|
||||
|
@ -561,12 +565,12 @@ impl ScriptInterpreter {
|
|||
|
||||
if value.is_empty() {
|
||||
return None;
|
||||
};
|
||||
}
|
||||
|
||||
let path = PathBuf::from(value);
|
||||
if path.is_absolute() {
|
||||
return Some(path);
|
||||
};
|
||||
}
|
||||
|
||||
// Resolve the path relative to current directory.
|
||||
Some(CWD.join(path))
|
||||
|
@ -689,7 +693,7 @@ impl ScriptInterpreter {
|
|||
}
|
||||
Err(uv_python::Error::MissingEnvironment(_)) => {}
|
||||
Err(err) => warn!("Ignoring existing script environment: {err}"),
|
||||
};
|
||||
}
|
||||
|
||||
let client_builder = BaseClientBuilder::new()
|
||||
.connectivity(network_settings.connectivity)
|
||||
|
@ -849,7 +853,7 @@ impl ProjectInterpreter {
|
|||
}
|
||||
// If the environment is an empty directory, it's fine to use
|
||||
InvalidEnvironmentKind::Empty => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(uv_python::Error::Query(uv_python::InterpreterError::NotFound(path))) => {
|
||||
if path.is_symlink() {
|
||||
|
@ -862,7 +866,7 @@ impl ProjectInterpreter {
|
|||
}
|
||||
}
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
}
|
||||
|
||||
let client_builder = BaseClientBuilder::default()
|
||||
.connectivity(network_settings.connectivity)
|
||||
|
@ -1033,7 +1037,7 @@ impl WorkspacePython {
|
|||
"Using Python request `{}` from {source}",
|
||||
python_request.to_canonical_string()
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
source,
|
||||
|
@ -1098,7 +1102,7 @@ impl ScriptPython {
|
|||
|
||||
if let Some(python_request) = python_request.as_ref() {
|
||||
debug!("Using Python request {python_request} from {source}");
|
||||
};
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
source,
|
||||
|
|
|
@ -937,14 +937,14 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
|
|||
|
||||
// If `--system-site-packages` is enabled, add the system site packages to the ephemeral
|
||||
// environment.
|
||||
if base_interpreter
|
||||
.is_virtualenv()
|
||||
.then(|| {
|
||||
if if base_interpreter.is_virtualenv() {
|
||||
{
|
||||
PyVenvConfiguration::parse(base_interpreter.sys_prefix().join("pyvenv.cfg"))
|
||||
.is_ok_and(|cfg| cfg.include_system_site_packages())
|
||||
})
|
||||
.unwrap_or(false)
|
||||
{
|
||||
}
|
||||
} else {
|
||||
false
|
||||
} {
|
||||
ephemeral_env.set_system_site_packages()?;
|
||||
} else {
|
||||
ephemeral_env.clear_system_site_packages()?;
|
||||
|
@ -1068,7 +1068,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
|
|||
// Ensure `VIRTUAL_ENV` is set.
|
||||
if interpreter.is_virtualenv() {
|
||||
process.env(EnvVars::VIRTUAL_ENV, interpreter.sys_prefix().as_os_str());
|
||||
};
|
||||
}
|
||||
|
||||
// Spawn and wait for completion
|
||||
// Standard input, output, and error streams are all inherited
|
||||
|
|
|
@ -88,7 +88,7 @@ pub(crate) async fn find(
|
|||
warn_user!("{err}");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if show_version {
|
||||
writeln!(
|
||||
|
|
|
@ -463,7 +463,7 @@ pub(crate) async fn install(
|
|||
event.key.bold(),
|
||||
)?;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if preview.is_enabled() {
|
||||
|
|
|
@ -112,7 +112,7 @@ pub(crate) async fn list(
|
|||
Either::Right(download.url()),
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let installed =
|
||||
match kinds {
|
||||
|
@ -223,7 +223,7 @@ pub(crate) async fn list(
|
|||
Either::Right(url) => {
|
||||
url_or_none = Some((*url).to_string());
|
||||
}
|
||||
};
|
||||
}
|
||||
let version = key.version();
|
||||
let release = version.release();
|
||||
|
||||
|
|
|
@ -116,11 +116,11 @@ pub(crate) async fn pin(
|
|||
) {
|
||||
if resolved {
|
||||
return Err(err);
|
||||
};
|
||||
}
|
||||
warn_user_once!("{err}");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let request = if resolved {
|
||||
|
|
|
@ -254,7 +254,7 @@ async fn venv_impl(
|
|||
warn_user!("{err}");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
writeln!(
|
||||
printer.stderr(),
|
||||
|
|
|
@ -15,6 +15,6 @@ pub(crate) fn version(output_format: VersionFormat, buffer: &mut dyn std::io::Wr
|
|||
// Add a trailing newline
|
||||
writeln!(buffer)?;
|
||||
}
|
||||
};
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -564,7 +564,7 @@ impl TestContext {
|
|||
),
|
||||
"[SITE_PACKAGES]/".to_string(),
|
||||
));
|
||||
};
|
||||
}
|
||||
|
||||
// Filter non-deterministic temporary directory names
|
||||
// Note we apply this _after_ all the full paths to avoid breaking their matching
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
[toolchain]
|
||||
channel = "1.85"
|
||||
channel = "1.86"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue