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

Resolution types drop urls under specific circumstances #5294

Closed
konstin opened this issue Jul 22, 2024 · 1 comment · Fixed by #5312
Closed

Resolution types drop urls under specific circumstances #5294

konstin opened this issue Jul 22, 2024 · 1 comment · Fixed by #5312
Assignees
Labels
bug Something isn't working preview Experimental behavior

Comments

@konstin
Copy link
Member

konstin commented Jul 22, 2024

Summary

The problem: The fields below (and the subsequent petgraph code) are missing the url, so we can't tell apart edges that are only different by their url, but equal by package name and version. This means in specific cases like the one in the section below we drop a marker and install the wrong package.

pub(crate) from_version: Version,
pub(crate) from_extra: Option<ExtraName>,
pub(crate) from_dev: Option<GroupName>,
pub(crate) to_version: Version,
pub(crate) to_extra: Option<ExtraName>,
pub(crate) to_dev: Option<GroupName>,

Reproduction

Create two dependency edges in two different forks that have the same starting package name and version and the same target package name and version, but are different in their url.

[project]
name = "a3"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
  "a @ file:///home/ferris/projects/uv/debug/a1 ; python_version >='3.11'",
  "a @ file:///home/ferris/projects/uv/debug/a2 ; python_version <'3.11'"
]

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

[tool.hatch.metadata]
allow-direct-references = true

/home/ferris/projects/uv/debug/a1:

[project]
name = "a"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [
    "anyio==4.3.0",
]

[tool.uv]
dev-dependencies = []

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

/home/ferris/projects/uv/debug/a2:

[project]
name = "a"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = [
    "anyio==4.4.0",
]

[tool.uv]
dev-dependencies = []

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

In the lockfile, we're indeed missing the marker:

[[distribution]]
name = "a"
version = "0.1.0"
source = { directory = "/home/konsti/projects/uv/debug/a1" }
dependencies = [
    { name = "anyio", version = "4.3.0", source = { registry = "https://pypi.org/simple" } },
    { name = "anyio", version = "4.4.0", source = { registry = "https://pypi.org/simple" } },
]

Instead of respecting the markers, we always install a3 and anyio==4.4.0 for python 3.10-3.12.

@konstin konstin added the bug Something isn't working label Jul 22, 2024
@charliermarsh charliermarsh self-assigned this Jul 22, 2024
@charliermarsh
Copy link
Member

Thanks, makes sense.

@konstin konstin added the preview Experimental behavior label Jul 22, 2024
charliermarsh pushed a commit that referenced this issue Jul 22, 2024
Looking at how to merge identical forks, i found that the `Resolution`
can be simplified by treating it as a nodes and edges store (plus pins,
they are separate since they are per name-version, not per
(virtual-)package-version). This should also make #5294 more apparent,
which i didn't touch here.

I additionally added some doc comments to the `Resolution` types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working preview Experimental behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants