Skip to content

Commit

Permalink
Avoid including empty extras in resolution (#5306)
Browse files Browse the repository at this point in the history
## Summary

You can still generate instabilities, but at least it's consistent
between including and excluding the extra.

For example, this resolves to 54 and then 52 packages on re-run:

```toml
[project]
name = "transformers"
version = "4.39.0.dev0"
description = "State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow"
requires-python = ">=3.9.0"

dependencies = []

[project.optional-dependencies]
flax = ["jaxlib>=0.4.1,<=0.4.13"]
onnxruntime = ["onnxruntime>=1.4.0"]
ray = ["ray[tune]>=2.7.0"]
deepspeed-testing = [
  "dill<0.3.5",
  "datasets!=2.5.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
```

I think the difference is just somewhere in PubGrub -- like, we add an
extra dependency, so the iteration order gets changed, and we end up
with a different resolution at the end.

Closes #5285.
  • Loading branch information
charliermarsh authored Jul 22, 2024
1 parent f00c3f2 commit 84b351a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/uv-workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,17 @@ impl Workspace {
.as_ref()
.map(|optional_dependencies| {
// It's a `BTreeMap` so the keys are sorted.
optional_dependencies.keys().cloned().collect::<Vec<_>>()
optional_dependencies
.iter()
.filter_map(|(name, dependencies)| {
if dependencies.is_empty() {
None
} else {
Some(name)
}
})
.cloned()
.collect::<Vec<_>>()
})
.unwrap_or_default();

Expand Down

0 comments on commit 84b351a

Please sign in to comment.