Skip to content

Commit 4546f40

Browse files
committed
wip: fix early outs
1 parent d7ab551 commit 4546f40

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

crates/pixi_core/src/lock_file/update.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ use pixi_install_pypi::{
2828
LazyEnvironmentVariables, PyPIBuildConfig, PyPIContextConfig, PyPIEnvironmentUpdater,
2929
PyPIUpdateConfig,
3030
};
31-
use pixi_manifest::{ChannelPriority, EnvironmentName, FeaturesExt, HasFeaturesIter};
31+
use pixi_manifest::{ChannelPriority, EnvironmentName, FeaturesExt};
3232
use pixi_progress::global_multi_progress;
3333
use pixi_record::{ParseLockFileError, PixiRecord};
34+
use pixi_spec::SourceSpec;
3435
use pixi_utils::prefix::Prefix;
3536
use pixi_uv_context::UvResolutionContext;
3637
use pixi_uv_conversions::{
@@ -1907,35 +1908,27 @@ pub enum TaskResult {
19071908

19081909
/// Expands develop dependencies for a grouped environment.
19091910
///
1910-
/// Collects all develop dependencies from the features of the grouped environment,
1911-
/// converts them to DependencyOnlySource format, and uses the command dispatcher
1912-
/// to expand them into their build/host/run dependencies.
1911+
/// Takes the develop dependencies, converts them to DependencyOnlySource format,
1912+
/// and uses the command dispatcher to expand them into their build/host/run dependencies.
19131913
///
19141914
/// Returns `None` if there are no develop dependencies.
19151915
async fn expand_develop_dependencies(
1916-
group: &GroupedEnvironment<'_>,
1916+
develop_dependencies: IndexMap<PackageName, SourceSpec>,
1917+
group_name: GroupedEnvironmentName,
19171918
platform: Platform,
19181919
channel_config: &ChannelConfig,
19191920
channels: &[ChannelUrl],
19201921
virtual_packages: &[GenericVirtualPackage],
19211922
variants: &BTreeMap<String, Vec<String>>,
19221923
command_dispatcher: &CommandDispatcher,
19231924
) -> Result<Option<ExpandedDevSources>, SolveCondaEnvironmentError> {
1924-
// Collect develop dependencies from all features in the group
1925-
let mut develop_deps = IndexMap::new();
1926-
for feature in group.features() {
1927-
if let Some(deps) = feature.develop_dependencies(Some(platform)) {
1928-
develop_deps.extend(deps.into_owned());
1929-
}
1930-
}
1931-
19321925
// If there are no develop dependencies, return early
1933-
if develop_deps.is_empty() {
1926+
if develop_dependencies.is_empty() {
19341927
return Ok(None);
19351928
}
19361929

19371930
// Convert to Vec<DependencyOnlySource>
1938-
let dev_sources: Vec<DependencyOnlySource> = develop_deps
1931+
let dev_sources: Vec<DependencyOnlySource> = develop_dependencies
19391932
.into_iter()
19401933
.map(|(name, spec)| DependencyOnlySource {
19411934
source: spec,
@@ -1959,7 +1952,7 @@ async fn expand_develop_dependencies(
19591952
.await
19601953
.map_err(
19611954
|source| SolveCondaEnvironmentError::ExpandDevSourcesFailed {
1962-
environment_name: group.name(),
1955+
environment_name: group_name,
19631956
platform,
19641957
source,
19651958
},
@@ -1981,15 +1974,18 @@ async fn spawn_solve_conda_environment_task(
19811974
// Get the dependencies for this platform
19821975
let dependencies = group.combined_dependencies(Some(platform));
19831976

1977+
// Get the develop dependencies for this platform
1978+
let develop_dependencies = group.combined_develop_dependencies(Some(platform));
1979+
19841980
// Get solve options
19851981
let exclude_newer = group.exclude_newer();
19861982
let strategy = group.solve_strategy();
19871983

19881984
// Get the environment name
19891985
let group_name = group.name();
19901986

1991-
// Early out if there are no dependencies to solve.
1992-
if dependencies.is_empty() {
1987+
// Early out if there are no dependencies to solve and no develop dependencies to expand.
1988+
if dependencies.is_empty() && develop_dependencies.is_empty() {
19931989
return Ok(TaskResult::CondaGroupSolved(
19941990
group_name,
19951991
platform,
@@ -2028,7 +2024,8 @@ async fn spawn_solve_conda_environment_task(
20282024

20292025
// Expand develop dependencies if any
20302026
let expanded_develop = expand_develop_dependencies(
2031-
&group,
2027+
develop_dependencies,
2028+
group_name.clone(),
20322029
platform,
20332030
&channel_config,
20342031
&channels,
@@ -2051,6 +2048,16 @@ async fn spawn_solve_conda_environment_task(
20512048
Default::default()
20522049
};
20532050

2051+
// Early out if the final combined dependencies are still empty after expansion
2052+
if dependencies.is_empty() {
2053+
return Ok(TaskResult::CondaGroupSolved(
2054+
group_name,
2055+
platform,
2056+
PixiRecordsByName::default(),
2057+
Duration::default(),
2058+
));
2059+
}
2060+
20542061
let start = Instant::now();
20552062

20562063
// Solve the environment using the command dispatcher.

crates/pixi_core/src/workspace/grouped_environment.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ use std::fmt::Display;
22
use std::path::PathBuf;
33

44
use fancy_display::FancyDisplay;
5+
use indexmap::IndexMap;
56
use itertools::Either;
67
use pixi_consts::consts;
78
use pixi_manifest::{
89
EnvironmentName, Feature, HasFeaturesIter, HasWorkspaceManifest, SystemRequirements,
910
WorkspaceManifest,
1011
};
12+
use pixi_spec::SourceSpec;
1113
use pixi_utils::prefix::Prefix;
12-
use rattler_conda_types::{ChannelConfig, GenericVirtualPackage, Platform};
14+
use rattler_conda_types::{ChannelConfig, GenericVirtualPackage, PackageName, Platform};
1315

1416
use crate::{
1517
Workspace,
@@ -121,6 +123,24 @@ impl<'p> GroupedEnvironment<'p> {
121123
pub fn channel_config(&self) -> ChannelConfig {
122124
self.workspace().channel_config()
123125
}
126+
127+
/// Returns the combined develop dependencies for this grouped environment.
128+
///
129+
/// Develop dependencies from all features in the group are collected and
130+
/// merged. If multiple features define the same develop dependency, the
131+
/// last one wins (later features override earlier ones).
132+
pub fn combined_develop_dependencies(
133+
&self,
134+
platform: Option<Platform>,
135+
) -> IndexMap<PackageName, SourceSpec> {
136+
let mut result = IndexMap::new();
137+
for feature in self.features() {
138+
if let Some(deps) = feature.develop_dependencies(platform) {
139+
result.extend(deps.into_owned());
140+
}
141+
}
142+
result
143+
}
124144
}
125145

126146
impl<'p> HasWorkspaceRef<'p> for GroupedEnvironment<'p> {

0 commit comments

Comments
 (0)