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

Repeated markers in resolution-markers #9296

Open
charliermarsh opened this issue Nov 20, 2024 · 5 comments
Open

Repeated markers in resolution-markers #9296

charliermarsh opened this issue Nov 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@charliermarsh
Copy link
Member

If you lock:

[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12.0"
dependencies = []

[project.optional-dependencies]
cpu = [
  "torch>=2.5.1",
  "torchvision>=0.20.1",
]
cu124 = [
  "torch>=2.5.1",
  "torchvision>=0.20.1",
]

[tool.uv]
conflicts = [
  [
    { extra = "cpu" },
    { extra = "cu124" },
  ],
]
environments = ["platform_system != 'Darwin'", "platform_system == 'Darwin'"]

[tool.uv.sources]
torch = [
  { index = "pytorch-cpu", extra = "cpu", marker = "platform_system != 'Darwin'" },
]
torchvision = [
  { index = "pytorch-cpu", extra = "cpu", marker = "platform_system != 'Darwin'" },
]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

Then the top of the lockfile includes:

resolution-markers = [
    "platform_system != 'Darwin'",
    "platform_system != 'Darwin'",
    "platform_system != 'Darwin'",
    "platform_system == 'Darwin'",
    "platform_system == 'Darwin'",
    "platform_system == 'Darwin'",
]

And the packages have entries like:

[[package]]
name = "torch"
version = "2.5.1"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
    "platform_system != 'Darwin'",
    "platform_system != 'Darwin'",
    "platform_system != 'Darwin'",
    "platform_system == 'Darwin'",
    "platform_system == 'Darwin'",
    "platform_system == 'Darwin'",
]
@charliermarsh charliermarsh added the bug Something isn't working label Nov 20, 2024
@charliermarsh
Copy link
Member Author

@BurntSushi -- I think this is somehow related to #9289. When we first fork, we create three forks:

DEBUG fork: ResolverEnvironment { kind: Universal { initial_forks: [platform_system != 'Darwin', platform_system == 'Darwin'], markers: platform_system != 'Darwin', exclude: {ConflictItem { package: PackageName("project"), conflict: Extra(ExtraName("cu124")) }, ConflictItem { package: PackageName("project"), conflict: Extra(ExtraName("cpu")) }} } }
DEBUG fork: ResolverEnvironment { kind: Universal { initial_forks: [platform_system != 'Darwin', platform_system == 'Darwin'], markers: platform_system != 'Darwin', exclude: {ConflictItem { package: PackageName("project"), conflict: Extra(ExtraName("cu124")) }} } }
DEBUG fork: ResolverEnvironment { kind: Universal { initial_forks: [platform_system != 'Darwin', platform_system == 'Darwin'], markers: platform_system != 'Darwin', exclude: {ConflictItem { package: PackageName("project"), conflict: Extra(ExtraName("cpu")) }} } }

But those aren't "differentiated" in their markers.

@BurntSushi
Copy link
Member

Hmmm. This might be a separate issue from #9289. I think the problem here is that we've traditionally assumed that forks are disjoint based on markers. But with forking based on extras, multiple forks can have the same markers. So we might be able to just de-deduplicate them?

@charliermarsh
Copy link
Member Author

Maybe, I’m not sure though… The forks do represent something different than one another, but it’s not captured by the markers. Is that ok?

@BurntSushi
Copy link
Member

It should be captured by the conflicts written to the lock file.

I guess I do wonder if perhaps the forks need their markers associated with the specific conflicts that arise for that fork during resolution.

@charliermarsh
Copy link
Member Author

Yeah we may be able to dedupe. It just feels slightly off, so I'm unsure. Maybe just think on it as you solve the deeper issue around transitive deps with conflicts etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants