-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add extra-build-dependencies
#14735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extra-build-dependencies
#14735
Changes from all commits
74c5064
5108c1e
190a40c
4ca5770
a0876c4
c337cea
fa21bf0
6fb8618
8b5d931
a06aa47
1d2d9aa
db10dcb
c1020e6
bd55fda
5d9e877
dd30f38
7c0b08c
64fe2e8
f821f2a
0439b69
6c61c7f
33bb91a
285b8b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ use std::path::Path; | |
| use uv_configuration::SourceStrategy; | ||
| use uv_distribution_types::{IndexLocations, Requirement}; | ||
| use uv_normalize::PackageName; | ||
| use uv_workspace::pyproject::ToolUvSources; | ||
| use uv_pypi_types::VerbatimParsedUrl; | ||
| use uv_workspace::pyproject::{ExtraBuildDependencies, ToolUvSources}; | ||
| use uv_workspace::{ | ||
| DiscoveryOptions, MemberDiscovery, ProjectWorkspace, Workspace, WorkspaceCache, | ||
| }; | ||
|
|
@@ -203,3 +204,93 @@ impl BuildRequires { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| /// Lowered extra build dependencies with source resolution applied. | ||
| #[derive(Debug, Clone, Default)] | ||
| pub struct ExtraBuildRequires { | ||
| pub extra_build_dependencies: ExtraBuildDependencies, | ||
| } | ||
|
|
||
| impl ExtraBuildRequires { | ||
| /// Lower extra build dependencies from a workspace, applying source resolution. | ||
| pub fn from_workspace( | ||
| extra_build_dependencies: ExtraBuildDependencies, | ||
| workspace: &Workspace, | ||
| index_locations: &IndexLocations, | ||
| source_strategy: SourceStrategy, | ||
| ) -> Result<Self, MetadataError> { | ||
| match source_strategy { | ||
| SourceStrategy::Enabled => { | ||
| // Collect project sources and indexes | ||
| let project_indexes = workspace | ||
| .pyproject_toml() | ||
| .tool | ||
| .as_ref() | ||
| .and_then(|tool| tool.uv.as_ref()) | ||
| .and_then(|uv| uv.index.as_deref()) | ||
| .unwrap_or(&[]); | ||
|
|
||
| let empty_sources = BTreeMap::default(); | ||
| let project_sources = workspace | ||
| .pyproject_toml() | ||
| .tool | ||
| .as_ref() | ||
| .and_then(|tool| tool.uv.as_ref()) | ||
| .and_then(|uv| uv.sources.as_ref()) | ||
| .map(ToolUvSources::inner) | ||
| .unwrap_or(&empty_sources); | ||
|
|
||
| // Lower each package's extra build dependencies | ||
| let mut result = ExtraBuildDependencies::default(); | ||
| for (package_name, requirements) in extra_build_dependencies { | ||
| let lowered: Vec<uv_pep508::Requirement<VerbatimParsedUrl>> = requirements | ||
| .into_iter() | ||
| .flat_map(|requirement| { | ||
| let requirement_name = requirement.name.clone(); | ||
| let extra = requirement.marker.top_level_extra_name(); | ||
| let group = None; | ||
| LoweredRequirement::from_requirement( | ||
| requirement, | ||
| None, | ||
| workspace.install_path(), | ||
| project_sources, | ||
| project_indexes, | ||
| extra.as_deref(), | ||
| group, | ||
| index_locations, | ||
| workspace, | ||
| None, | ||
| ) | ||
| .map( | ||
| move |requirement| match requirement { | ||
| Ok(requirement) => Ok(requirement.into_inner().into()), | ||
| Err(err) => Err(MetadataError::LoweringError( | ||
| requirement_name.clone(), | ||
| Box::new(err), | ||
| )), | ||
| }, | ||
| ) | ||
| }) | ||
| .collect::<Result<Vec<_>, _>>()?; | ||
| result.insert(package_name, lowered); | ||
| } | ||
| Ok(Self { | ||
| extra_build_dependencies: result, | ||
| }) | ||
| } | ||
| SourceStrategy::Disabled => { | ||
| // Without source resolution, just return the dependencies as-is | ||
| Ok(Self { | ||
| extra_build_dependencies, | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Create from pre-lowered dependencies (for non-workspace contexts). | ||
| pub fn from_lowered(extra_build_dependencies: ExtraBuildDependencies) -> Self { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this just be a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This separate method avoids accidentally converting them without lowering
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think a dedicated method makes sense here. |
||
| Self { | ||
| extra_build_dependencies, | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.