Skip to content

Commit

Permalink
Add a "default" SolveGroup to the default Environment (if not redefined)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-lacroix committed Mar 31, 2024
1 parent bbe7d9e commit 60047b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
7 changes: 7 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,13 @@ prod = {features = ["prod"], solve-group = "test"}
lint = ["lint"]
```

Unless the `default` environment is redefined, it is included in the `default` solve group. That is, the following is implied unless overridden in the manifest's `[environments]` table:
```toml title="default environment"
[environments]
default = { features = [], solve-group = "default" } # the default environment includes the 'default' feature only
```


## Global configuration

The global configuration options are documented in the [global configuration](advanced/global_configuration.md) section.
1 change: 0 additions & 1 deletion src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ platforms = {{ platforms }}
{%- if loop.first %}
[tool.pixi.environments]
default = { features = [], solve-group = "default" }
{%- endif %}
{{env}} = { features = {{ features }}, solve-group = "default" }
{%- endfor %}
Expand Down
23 changes: 13 additions & 10 deletions src/project/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,17 @@ impl SolveGroups {
pub fn iter(&self) -> impl Iterator<Item = &SolveGroup> + '_ {
self.solve_groups.iter()
}

/// Inserts a SolveGroup based on a name and an environment index
pub fn insert(&mut self, name: &str, environment_idx: usize) -> usize {
let idx = self.solve_groups.len();
self.solve_groups.push(SolveGroup {
name: name.to_string(),
environments: vec![environment_idx],
});
self.by_name.insert(name.to_string(), idx);
idx
}
}

/// Describes the contents of a project manifest.
Expand Down Expand Up @@ -1022,7 +1033,7 @@ impl<'de> Deserialize<'de> for ProjectManifest {
name: EnvironmentName::Default,
features: Vec::new(),
features_source_loc: None,
solve_group: None,
solve_group: Some(solve_groups.insert("default", 0)),
});
environments.by_name.insert(EnvironmentName::Default, 0);
}
Expand All @@ -1049,15 +1060,7 @@ impl<'de> Deserialize<'de> for ProjectManifest {
.push(environment_idx);
*idx
}
None => {
let idx = solve_groups.solve_groups.len();
solve_groups.solve_groups.push(SolveGroup {
name: solve_group.clone(),
environments: vec![environment_idx],
});
solve_groups.by_name.insert(solve_group, idx);
idx
}
None => solve_groups.insert(&solve_group, environment_idx),
})
} else {
None
Expand Down
6 changes: 3 additions & 3 deletions src/project/solve_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ mod tests {
let foo_environment = project.environment("foo").unwrap();
let bar_environment = project.environment("bar").unwrap();

let solve_groups = project.solve_groups();
assert_eq!(solve_groups.len(), 1);
let solve_groups = project.solve_groups(); // contains 'default', 'group1'
assert_eq!(solve_groups.len(), 2);

let solve_group = solve_groups[0].clone();
let solve_group = solve_groups[1].clone(); // 'group1' solve group
let solve_group_envs = solve_group.environments().collect_vec();
assert_eq!(solve_group_envs.len(), 2);
assert_eq!(solve_group_envs[0].name(), "foo");
Expand Down

0 comments on commit 60047b2

Please sign in to comment.