Skip to content

Remove extra duplication from lockfile #4888

Description

@konstin

When declaring a dependency pandas[excel,html,plot], the lockfile shows:

dependencies = [
    { name = "pandas" },
    { name = "pandas", extra = "excel" },
    { name = "pandas", extra = "html" },
    { name = "pandas", extra = "plot" },
]

We should collapse those entries:

dependencies = [
    { name = "pandas", extra = ["excel", "html", "plot"] },
]

This makes more sense to the user (we don't install pandas four times, we install it once and then those extra packages, that's our internal abstraction into virtual packages leaking) and makes the lockfile more concise.

Activity

  1. BurntSushi commented on Jul 8, 2024

    @BurntSushi
    Member

    Is this limited to the specific example shown here, or in general? In general, each of those dependency entries can have other fields on them that are different. For example, markers. In theory, I think, other fields could be different too, such as version and source. Or at least, that's what our data model supports. But I think the markers really could be different?

  2. konstin commented on Jul 8, 2024

    @konstin
    MemberAuthor

    This should only collapse entries with the same markers. Say we have

    dependencies = [
        "pandas[excel,html]; python_version == '3.13'",
        "pandas[excel,plot]",
    ]

    we currently get

    dependencies = [
        { name = "pandas" },
        { name = "pandas", extra = "excel" },
        { name = "pandas", extra = "html", marker = "python_version == '3.13'" },
        { name = "pandas", extra = "plot" },
    ]

    which we could collapse to

    dependencies = [
        { name = "pandas", extras = ["excel", "plot"] },
        { name = "pandas", extras = ["html"], marker = "python_version == '3.13'" },
    ]
  3. BurntSushi commented on Jul 8, 2024

    @BurntSushi
    Member

    Right, okay. I think this LGTM. Although I don't totally mind our existing format, I am very sympathetic to the fact that it leaks our "virtual package" abstraction. So I think I would on balance favor your suggestion here to the status quo.

  4. self-assigned this
    on Jul 18, 2024
  5. added a commit that references this issue on Jul 18, 2024
    55de9f8
  6. added a commit that references this issue on Jul 18, 2024
    5bcdaed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

previewExperimental behavior

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions