Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ dunce = { version = "1.0.5" }
either = { version = "1.13.0" }
encoding_rs_io = { version = "0.1.7" }
embed-manifest = { version = "1.5.0" }
enumflags2 = { version = "0.7.12" }
etcetera = { version = "0.11.0" }
fastrand = { version = "2.3.0" }
flate2 = { version = "1.0.33", default-features = false, features = ["zlib-rs"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-auth/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use reqwest_middleware::{ClientWithMiddleware, Error, Middleware, Next};
use tokio::sync::Mutex;
use tracing::{debug, trace, warn};

use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};
use uv_redacted::DisplaySafeUrl;
use uv_static::EnvVars;
use uv_warnings::owo_colors::OwoColorize;
Expand Down Expand Up @@ -815,7 +815,7 @@ impl AuthMiddleware {
debug!("Found credentials in plaintext store for {url}");
Some(credentials)
} else if let Some(credentials) = {
if self.preview.is_enabled(PreviewFeatures::NATIVE_AUTH) {
if self.preview.is_enabled(PreviewFeature::NativeAuth) {
let native_store = KeyringProvider::native();
let username = credentials.and_then(|credentials| credentials.username());
let display_username = if let Some(username) = username {
Expand Down
10 changes: 5 additions & 5 deletions crates/uv-auth/src/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use reqsign::google::DefaultSigner as GcsDefaultSigner;
use tracing::debug;
use url::Url;

use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};
use uv_static::EnvVars;
use uv_warnings::warn_user_once;

Expand Down Expand Up @@ -70,10 +70,10 @@ impl S3EndpointProvider {
/// Returns `true` if the URL matches the configured S3 endpoint.
pub(crate) fn is_s3_endpoint(url: &Url, preview: Preview) -> bool {
if let Some(s3_endpoint_realm) = S3_ENDPOINT_REALM.as_ref().map(RealmRef::from) {
if !preview.is_enabled(PreviewFeatures::S3_ENDPOINT) {
if !preview.is_enabled(PreviewFeature::S3Endpoint) {
warn_user_once!(
"The `s3-endpoint` option is experimental and may change without warning. Pass `--preview-features {}` to disable this warning.",
PreviewFeatures::S3_ENDPOINT
PreviewFeature::S3Endpoint
);
}

Expand Down Expand Up @@ -119,10 +119,10 @@ impl GcsEndpointProvider {
/// Returns `true` if the URL matches the configured GCS endpoint.
pub(crate) fn is_gcs_endpoint(url: &Url, preview: Preview) -> bool {
if let Some(gcs_endpoint_realm) = GCS_ENDPOINT_REALM.as_ref().map(RealmRef::from) {
if !preview.is_enabled(PreviewFeatures::GCS_ENDPOINT) {
if !preview.is_enabled(PreviewFeature::GcsEndpoint) {
warn_user_once!(
"The `gcs-endpoint` option is experimental and may change without warning. Pass `--preview-features {}` to disable this warning.",
PreviewFeatures::GCS_ENDPOINT
PreviewFeature::GcsEndpoint
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv-auth/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use uv_fs::{LockedFile, LockedFileError, LockedFileMode, with_added_extension};
use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};
use uv_redacted::DisplaySafeUrl;

use uv_state::{StateBucket, StateStore};
Expand All @@ -30,7 +30,7 @@ pub enum AuthBackend {
impl AuthBackend {
pub async fn from_settings(preview: Preview) -> Result<Self, TomlCredentialError> {
// If preview is enabled, we'll use the system-native store
if preview.is_enabled(PreviewFeatures::NATIVE_AUTH) {
if preview.is_enabled(PreviewFeature::NativeAuth) {
return Ok(Self::System(KeyringProvider::native()));
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ mod tests {
use tempfile::TempDir;
use uv_distribution_filename::{SourceDistFilename, WheelFilename};
use uv_fs::{copy_dir_all, relative_to};
use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};

const MOCK_UV_VERSION: &str = "1.0.0+test";

Expand Down Expand Up @@ -1810,7 +1810,7 @@ mod tests {
let build = build(
src.path(),
dist.path(),
Preview::new(PreviewFeatures::METADATA_JSON),
Preview::new(&[PreviewFeature::MetadataJson]),
)
.unwrap();

Expand Down
6 changes: 3 additions & 3 deletions crates/uv-build-backend/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use uv_distribution_filename::WheelFilename;
use uv_fs::Simplified;
use uv_globfilter::{GlobDirFilter, PortableGlobParser};
use uv_platform_tags::{AbiTag, LanguageTag, PlatformTag};
use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};
use uv_warnings::warn_user_once;

use crate::metadata::DEFAULT_EXCLUDES;
Expand Down Expand Up @@ -611,7 +611,7 @@ fn write_dist_info(
&format!("{dist_info_dir}/WHEEL"),
wheel_info.to_string().as_bytes(),
)?;
if preview.is_enabled(PreviewFeatures::METADATA_JSON) {
if preview.is_enabled(PreviewFeature::MetadataJson) {
writer.write_bytes(
&format!("{dist_info_dir}/WHEEL.json"),
&serde_json::to_vec(&wheel_info).map_err(Error::Json)?,
Expand All @@ -632,7 +632,7 @@ fn write_dist_info(
&format!("{dist_info_dir}/METADATA"),
metadata.core_metadata_format().as_bytes(),
)?;
if preview.is_enabled(PreviewFeatures::METADATA_JSON) {
if preview.is_enabled(PreviewFeature::MetadataJson) {
writer.write_bytes(
&format!("{dist_info_dir}/METADATA.json"),
&serde_json::to_vec(&metadata).map_err(Error::Json)?,
Expand Down
34 changes: 16 additions & 18 deletions crates/uv-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
use uv_preview::{Preview, PreviewFeatures};
use uv_preview::Preview;
use uv_static::{EnvVars, parse_boolish_environment_variable};

use anyhow::{Context, Result, bail};
Expand Down Expand Up @@ -42,23 +42,21 @@ fn main() -> Result<()> {
.to_string();

// Ad-hoc preview features parsing due to a lack of clap CLI in uv-build.
let preview_features =
if parse_boolish_environment_variable(EnvVars::UV_PREVIEW)?.unwrap_or(false) {
PreviewFeatures::all()
} else if let Some(preview_features) = env::var_os(EnvVars::UV_PREVIEW_FEATURES) {
let preview_features = preview_features
.to_str()
.with_context(|| format!("Invalid UTF-8 in `{}`", EnvVars::UV_PREVIEW_FEATURES))?;
PreviewFeatures::from_str(preview_features).with_context(|| {
format!(
"Invalid preview features list in `{}`",
EnvVars::UV_PREVIEW_FEATURES
)
})?
} else {
PreviewFeatures::default()
};
let preview = Preview::new(preview_features);
let preview = if parse_boolish_environment_variable(EnvVars::UV_PREVIEW)?.unwrap_or(false) {
Preview::all()
} else if let Some(preview_features) = env::var_os(EnvVars::UV_PREVIEW_FEATURES) {
let preview_features = preview_features
.to_str()
.with_context(|| format!("Invalid UTF-8 in `{}`", EnvVars::UV_PREVIEW_FEATURES))?;
Preview::from_str(preview_features).with_context(|| {
format!(
"Invalid preview features list in `{}`",
EnvVars::UV_PREVIEW_FEATURES
)
})?
} else {
Preview::default()
};
match command.as_str() {
"build-sdist" => {
let sdist_directory = PathBuf::from(args.next().context("Missing sdist directory")?);
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use uv_distribution_types::{
};
use uv_normalize::{ExtraName, GroupName, PackageName, PipGroupName};
use uv_pep508::{MarkerTree, Requirement};
use uv_preview::PreviewFeatures;
use uv_preview::PreviewFeature;
use uv_pypi_types::VerbatimParsedUrl;
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
use uv_redacted::DisplaySafeUrl;
Expand Down Expand Up @@ -306,7 +306,7 @@ pub struct GlobalArgs {
alias = "preview-feature",
value_enum,
)]
pub preview_features: Vec<PreviewFeatures>,
pub preview_features: Vec<PreviewFeature>,

/// Avoid discovering a `pyproject.toml` or `uv.toml` file [env: UV_ISOLATED=]
///
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-install-wheel/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use walkdir::WalkDir;

use uv_distribution_filename::WheelFilename;
use uv_fs::Simplified;
use uv_preview::{Preview, PreviewFeatures};
use uv_preview::{Preview, PreviewFeature};
use uv_warnings::{warn_user, warn_user_once};

use crate::Error;
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Locks {
// This warning is currently in preview.
if !self
.preview
.is_enabled(PreviewFeatures::DETECT_MODULE_CONFLICTS)
.is_enabled(PreviewFeature::DetectModuleConflicts)
{
return Ok(());
}
Expand Down
3 changes: 2 additions & 1 deletion crates/uv-preview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ workspace = true
[dependencies]
uv-warnings = { workspace = true }

bitflags = { workspace = true }
enumflags2 = { workspace = true }
itertools = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
Expand Down
Loading