Skip to content

Commit

Permalink
Merge branch 'astral-sh:main' into doc_pip_compatibility_pip_install_…
Browse files Browse the repository at this point in the history
…folder
  • Loading branch information
FishAlchemist authored Nov 13, 2024
2 parents 3d16ad4 + 95e7d87 commit 05954d8
Show file tree
Hide file tree
Showing 53 changed files with 1,666 additions and 1,159 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ exclude: |
repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
rev: v0.23
hooks:
- id: validate-pyproject

- repo: https://github.com/crate-ci/typos
rev: v1.27.0
rev: v1.27.3
hooks:
- id: typos

Expand Down Expand Up @@ -42,7 +42,7 @@ repos:
types_or: [yaml, json5]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.7.3
hooks:
- id: ruff-format
- id: ruff
Expand Down
18 changes: 10 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ anyhow = { version = "1.0.89" }
async-channel = { version = "2.3.1" }
async-compression = { version = "0.4.12" }
async-trait = { version = "0.1.82" }
async_http_range_reader = { version = "0.9.0" }
async_http_range_reader = { version = "0.9.1" }
async_zip = { git = "https://github.com/charliermarsh/rs-async-zip", rev = "011b24604fa7bc223daaad7712c0694bac8f0a87", features = ["deflate", "tokio"] }
axoupdater = { version = "0.8.0", default-features = false }
backoff = { version = "0.4.0" }
Expand Down Expand Up @@ -120,22 +120,22 @@ md-5 = { version = "0.10.6" }
memchr = { version = "2.7.4" }
miette = { version = "7.2.0" }
nanoid = { version = "0.4.0" }
nix = { version = "0.29.0" }
owo-colors = { version = "4.1.0" }
path-slash = { version = "0.2.1" }
pathdiff = { version = "0.2.1" }
petgraph = { version = "0.6.5" }
platform-info = { version = "2.0.3" }
procfs = { version = "0.17.0", default-features = false, features = ["flate2"] }
proc-macro2 = { version = "1.0.86" }
procfs = { version = "0.17.0", default-features = false, features = ["flate2"] }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "95e1390399cdddee986b658be19587eb1fdb2d79" }
version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "95e1390399cdddee986b658be19587eb1fdb2d79" }
quote = { version = "1.0.37" }
rayon = { version = "1.10.0" }
reflink-copy = { version = "0.1.19" }
regex = { version = "1.10.6" }
reqwest = { version = "0.12.7", default-features = false, features = ["json", "gzip", "stream", "rustls-tls", "rustls-tls-native-roots", "socks", "multipart", "http2"] }
reqwest-middleware = { git = "https://github.com/TrueLayer/reqwest-middleware", rev = "d95ec5a99fcc9a4339e1850d40378bbfe55ab121", features = ["multipart"] }
reqwest-retry = { git = "https://github.com/TrueLayer/reqwest-middleware", rev = "d95ec5a99fcc9a4339e1850d40378bbfe55ab121" }
reqwest-middleware = { version = "0.4.0", features = ["multipart"] }
reqwest-retry = { version = "0.7.0" }
rkyv = { version = "0.8.8", features = ["bytecheck"] }
rmp-serde = { version = "1.3.0" }
rust-netrc = { version = "0.1.2" }
Expand Down Expand Up @@ -172,6 +172,7 @@ unicode-width = { version = "0.1.13" }
unscanny = { version = "0.1.0" }
url = { version = "2.5.2" }
urlencoding = { version = "2.1.3" }
version-ranges = { git = "https://github.com/astral-sh/pubgrub", rev = "95e1390399cdddee986b658be19587eb1fdb2d79" }
walkdir = { version = "2.5.0" }
which = { version = "7.0.0", features = ["regex"] }
windows-registry = { version = "0.3.0" }
Expand All @@ -186,9 +187,6 @@ zip = { version = "0.6.6", default-features = false, features = ["deflate"] }
[workspace.metadata.cargo-shear]
ignored = ["flate2", "xz2"]

[patch.crates-io]
reqwest-middleware = { git = "https://github.com/TrueLayer/reqwest-middleware", rev = "d95ec5a99fcc9a4339e1850d40378bbfe55ab121" }

[workspace.lints.rust]
unsafe_code = "warn"
unreachable_pub = "warn"
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,7 @@ pub struct PipTreeArgs {
)]
pub system: bool,

#[arg(long, overrides_with("system"))]
#[arg(long, overrides_with("system"), hide = true)]
pub no_system: bool,

#[command(flatten)]
Expand Down
43 changes: 23 additions & 20 deletions crates/uv-dev/src/generate_env_vars_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use anyhow::bail;
use pretty_assertions::StrComparison;
use std::collections::BTreeSet;
use std::path::PathBuf;

use uv_static::EnvVars;
Expand Down Expand Up @@ -71,30 +72,32 @@ fn generate() -> String {
let mut output = String::new();

output.push_str("# Environment variables\n\n");
output.push_str("uv respects the following environment variables:\n\n");

for (var, doc) in EnvVars::metadata() {
// Remove empty lines and ddd two spaces to the beginning from the second line.
let doc = doc
.lines()
.enumerate()
.filter(|(_, line)| !line.trim().is_empty())
.map(|(i, line)| {
if i == 0 {
line.to_string()
} else {
format!(" {line}")
}
})
.collect::<Vec<_>>()
.join("\n");
output.push_str(&format!(
"- <a id=\"{var}\"></a> [`{var}`](#{var}): {doc}\n"
));

// Partition and sort environment variables into UV_ and external variables.
let (uv_vars, external_vars): (BTreeSet<_>, BTreeSet<_>) = EnvVars::metadata()
.iter()
.partition(|(var, _)| var.starts_with("UV_"));

output.push_str("uv defines and respects the following environment variables:\n\n");

for (var, doc) in uv_vars {
output.push_str(&render(var, doc));
}

output.push_str("\n\n## Externally defined variables\n\n");
output.push_str("uv also reads the following externally defined environment variables:\n\n");

for (var, doc) in external_vars {
output.push_str(&render(var, doc));
}

output
}

/// Render an environment variable and its documentation.
fn render(var: &str, doc: &str) -> String {
format!("### `{var}`\n\n{doc}\n\n")
}

#[cfg(test)]
mod tests;
5 changes: 1 addition & 4 deletions crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ impl<'a> BuildContext for BuildDispatch<'a> {
remote.iter().map(ToString::to_string).join(", ")
);

preparer
.prepare(remote, self.in_flight)
.await
.context("Failed to prepare distributions")?
preparer.prepare(remote, self.in_flight).await?
};

// Remove any unnecessary packages.
Expand Down
1 change: 0 additions & 1 deletion crates/uv-installer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ uv-cache-key = { workspace = true }
uv-configuration = { workspace = true }
uv-distribution = { workspace = true }
uv-distribution-types = { workspace = true }
uv-extract = { workspace = true }
uv-fs = { workspace = true }
uv-install-wheel = { workspace = true, default-features = false }
uv-normalize = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-installer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use compile::{compile_tree, CompileError};
pub use installer::{Installer, Reporter as InstallReporter};
pub use plan::{Plan, Planner};
pub use preparer::{Preparer, Reporter as PrepareReporter};
pub use preparer::{Error as PrepareError, Preparer, Reporter as PrepareReporter};
pub use site_packages::{SatisfiesResult, SitePackages, SitePackagesDiagnostic};
pub use uninstall::{uninstall, UninstallError};

Expand Down
34 changes: 12 additions & 22 deletions crates/uv-installer/src/preparer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use std::cmp::Reverse;
use std::sync::Arc;

use futures::{stream::FuturesUnordered, FutureExt, Stream, TryFutureExt, TryStreamExt};
use tokio::task::JoinError;
use tracing::{debug, instrument};
use url::Url;
use uv_pep508::PackageName;

use uv_cache::Cache;
use uv_configuration::BuildOptions;
Expand All @@ -14,6 +12,7 @@ use uv_distribution_types::{
BuildableSource, BuiltDist, CachedDist, Dist, Hashed, Identifier, Name, RemoteSource,
SourceDist,
};
use uv_pep508::PackageName;
use uv_platform_tags::Tags;
use uv_types::{BuildContext, HashStrategy, InFlight};

Expand All @@ -23,21 +22,12 @@ pub enum Error {
NoBuild(PackageName),
#[error("Using pre-built wheels is disabled, but attempted to use `{0}`")]
NoBinary(PackageName),
#[error("Failed to unzip wheel: {0}")]
Unzip(Dist, #[source] Box<uv_extract::Error>),
#[error("Failed to download `{0}`")]
Fetch(BuiltDist, #[source] Box<uv_distribution::Error>),
Download(Box<BuiltDist>, #[source] uv_distribution::Error),
#[error("Failed to download and build `{0}`")]
FetchAndBuild(SourceDist, #[source] Box<uv_distribution::Error>),
DownloadAndBuild(Box<SourceDist>, #[source] uv_distribution::Error),
#[error("Failed to build `{0}`")]
Build(SourceDist, #[source] Box<uv_distribution::Error>),
/// Should not occur; only seen when another task panicked.
#[error("The task executor is broken, did some other task panic?")]
Join(#[from] JoinError),
#[error(transparent)]
Editable(#[from] Box<uv_distribution::Error>),
#[error("Failed to write to the client cache")]
CacheWrite(#[source] std::io::Error),
Build(Box<SourceDist>, #[source] uv_distribution::Error),
#[error("Unzip failed in another thread: {0}")]
Thread(String),
}
Expand Down Expand Up @@ -155,13 +145,13 @@ impl<'a, Context: BuildContext> Preparer<'a, Context> {
.database
.get_or_build_wheel(&dist, self.tags, policy)
.boxed_local()
.map_err(|err| match &dist {
Dist::Built(dist) => Error::Fetch(dist.clone(), Box::new(err)),
.map_err(|err| match dist.clone() {
Dist::Built(dist) => Error::Download(Box::new(dist), err),
Dist::Source(dist) => {
if dist.is_local() {
Error::Build(dist.clone(), Box::new(err))
Error::Build(Box::new(dist), err)
} else {
Error::FetchAndBuild(dist.clone(), Box::new(err))
Error::DownloadAndBuild(Box::new(dist), err)
}
}
})
Expand All @@ -175,13 +165,13 @@ impl<'a, Context: BuildContext> Preparer<'a, Context> {
policy.digests(),
wheel.hashes(),
);
Err(match &dist {
Dist::Built(dist) => Error::Fetch(dist.clone(), Box::new(err)),
Err(match dist {
Dist::Built(dist) => Error::Download(Box::new(dist), err),
Dist::Source(dist) => {
if dist.is_local() {
Error::Build(dist.clone(), Box::new(err))
Error::Build(Box::new(dist), err)
} else {
Error::FetchAndBuild(dist.clone(), Box::new(err))
Error::DownloadAndBuild(Box::new(dist), err)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-pep440/src/version_specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl VersionSpecifiers {
self.iter().all(|specifier| specifier.contains(version))
}

/// Returns `true` if the specifiers are empty is empty.
/// Returns `true` if there are no specifiers.
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
Expand Down
8 changes: 4 additions & 4 deletions crates/uv-requirements/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ impl<'a, Context: BuildContext> ExtrasResolver<'a, Context> {
let archive = database
.get_or_build_wheel_metadata(&dist, hasher.get(&dist))
.await
.map_err(|err| match &dist {
Dist::Built(built) => Error::Download(built.clone(), err),
.map_err(|err| match dist {
Dist::Built(built) => Error::Download(Box::new(built), err),
Dist::Source(source) => {
if source.is_local() {
Error::Build(source.clone(), err)
Error::Build(Box::new(source), err)
} else {
Error::DownloadAndBuild(source.clone(), err)
Error::DownloadAndBuild(Box::new(source), err)
}
}
})?;
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-requirements/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub mod upgrade;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Failed to download `{0}`")]
Download(BuiltDist, #[source] uv_distribution::Error),
Download(Box<BuiltDist>, #[source] uv_distribution::Error),

#[error("Failed to download and build `{0}`")]
DownloadAndBuild(SourceDist, #[source] uv_distribution::Error),
DownloadAndBuild(Box<SourceDist>, #[source] uv_distribution::Error),

#[error("Failed to build `{0}`")]
Build(SourceDist, #[source] uv_distribution::Error),
Build(Box<SourceDist>, #[source] uv_distribution::Error),

#[error(transparent)]
Distribution(#[from] uv_distribution::Error),
Expand Down
Loading

0 comments on commit 05954d8

Please sign in to comment.