Refactor ExtraSpecification to support default-extras (#12964)

## Summary

Part of #8607. This is a pure refactor aimed at paving the way for
supporting the `default-extras` configuration in the `pyproject.toml`
file.

The `ExtraSpecification` struct has been refactored to align more
closely with the
[`DependencyGroups`](256b100a9e/crates/uv-configuration/src/dependency_groups.rs (L9))
struct.

## Test Plan

Existing tests.
This commit is contained in:
Ahmed Ilyas 2025-04-28 19:30:14 +02:00 committed by GitHub
parent 85d8b07026
commit f872917d33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1164 additions and 294 deletions

View file

@ -8,7 +8,9 @@ use petgraph::visit::IntoNodeReferences;
use petgraph::{Direction, Graph};
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use uv_configuration::{DependencyGroupsWithDefaults, ExtrasSpecification, InstallOptions};
use uv_configuration::{
DependencyGroupsWithDefaults, ExtrasSpecificationWithDefaults, InstallOptions,
};
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_pep508::MarkerTree;
use uv_pypi_types::ConflictItem;
@ -43,7 +45,7 @@ impl<'lock> ExportableRequirements<'lock> {
fn from_lock(
target: &impl Installable<'lock>,
prune: &[PackageName],
extras: &ExtrasSpecification,
extras: &ExtrasSpecificationWithDefaults,
dev: &DependencyGroupsWithDefaults,
annotate: bool,
install_options: &'lock InstallOptions,

View file

@ -13,7 +13,7 @@ use url::Url;
use uv_cache_key::RepositoryUrl;
use uv_configuration::{
BuildOptions, DependencyGroupsWithDefaults, ExtrasSpecification, InstallOptions,
BuildOptions, DependencyGroupsWithDefaults, ExtrasSpecificationWithDefaults, InstallOptions,
};
use uv_distribution_filename::{
BuildTag, DistExtension, ExtensionError, SourceDistExtension, SourceDistFilename,
@ -584,7 +584,7 @@ impl<'lock> PylockToml {
pub fn from_lock(
target: &impl Installable<'lock>,
prune: &[PackageName],
extras: &ExtrasSpecification,
extras: &ExtrasSpecificationWithDefaults,
dev: &DependencyGroupsWithDefaults,
annotate: bool,
install_options: &'lock InstallOptions,

View file

@ -6,7 +6,7 @@ use owo_colors::OwoColorize;
use url::Url;
use uv_configuration::{
DependencyGroupsWithDefaults, EditableMode, ExtrasSpecification, InstallOptions,
DependencyGroupsWithDefaults, EditableMode, ExtrasSpecificationWithDefaults, InstallOptions,
};
use uv_distribution_filename::{DistExtension, SourceDistExtension};
use uv_fs::Simplified;
@ -30,7 +30,7 @@ impl<'lock> RequirementsTxtExport<'lock> {
pub fn from_lock(
target: &impl Installable<'lock>,
prune: &[PackageName],
extras: &ExtrasSpecification,
extras: &ExtrasSpecificationWithDefaults,
dev: &DependencyGroupsWithDefaults,
annotate: bool,
editable: EditableMode,

View file

@ -9,9 +9,8 @@ use itertools::Itertools;
use petgraph::Graph;
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
use uv_configuration::{
BuildOptions, DependencyGroupsWithDefaults, ExtrasSpecification, InstallOptions,
};
use uv_configuration::ExtrasSpecificationWithDefaults;
use uv_configuration::{BuildOptions, DependencyGroupsWithDefaults, InstallOptions};
use uv_distribution_types::{Edge, Node, Resolution, ResolvedDist};
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_pep508::MarkerTree;
@ -39,7 +38,7 @@ pub trait Installable<'lock> {
&self,
marker_env: &ResolverMarkerEnvironment,
tags: &Tags,
extras: &ExtrasSpecification,
extras: &ExtrasSpecificationWithDefaults,
dev: &DependencyGroupsWithDefaults,
build_options: &BuildOptions,
install_options: &InstallOptions,