Skip to content
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

fix: issue with invalid solve group #1190

Merged
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
13 changes: 12 additions & 1 deletion src/project/manifest/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl fmt::Display for FeatureName {
///
/// Individual features cannot be used directly, instead they are grouped together into
/// environments. Environments are then locked and installed.
#[derive(Debug, Clone, Default)]
#[derive(Debug, Clone)]
pub struct Feature {
/// The name of the feature or `None` if the feature is the default feature.
pub name: FeatureName,
Expand All @@ -132,6 +132,17 @@ pub struct Feature {
}

impl Feature {
/// Construct a new feature with the given name.
pub fn new(name: FeatureName) -> Self {
Feature {
name,
platforms: None,
channels: None,
system_requirements: SystemRequirements::default(),
targets: <Targets as Default>::default(),
}
}

/// Returns true if this feature is the default feature.
pub fn is_default(&self) -> bool {
self.name == FeatureName::Default
Expand Down
6 changes: 5 additions & 1 deletion src/project/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,11 @@ impl Manifest {
name: Option<&FeatureName>,
) -> &mut Target {
let feature = match name {
Some(feature) => self.parsed.features.entry(feature.clone()).or_default(),
Some(feature) => self
.parsed
.features
.entry(feature.clone())
.or_insert_with(|| Feature::new(feature.clone())),
None => self.default_feature_mut(),
};
feature
Expand Down
7 changes: 4 additions & 3 deletions src/project/manifest/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::FeatureName;
use super::{
error::{RequirementConversionError, TomlError},
python::PyPiPackageName,
ProjectManifest, PyPiRequirement, SpecType,
Feature, ProjectManifest, PyPiRequirement, SpecType,
};

#[derive(Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -106,10 +106,11 @@ impl From<PyProjectManifest> for ProjectManifest {
for (extra, reqs) in extras {
// Filter out unused features
if features_used.contains(extra) {
let feature_name = FeatureName::Named(extra.to_string());
let target = manifest
.features
.entry(FeatureName::Named(extra.to_string()))
.or_default()
.entry(feature_name.clone())
.or_insert_with(move || Feature::new(feature_name))
.targets
.default_mut();
for req in reqs.iter() {
Expand Down
Loading