Skip to content

Emit index urls in uv export same way as uv pip compile --emit-index-url #10008

@Fogapod

Description

@Fogapod

I am exporting uv.lock to requirements.txt for bazel.
I have torch index overrides which aren't exported and produce impossible to insall requirements file:

[tool.uv.sources]
torch = [
    { index = "pytorch-cpu" },
]

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

results in:

torch==2.5.1+cpu \
    --hash=sha256:4856f9d6925121d13c2df07aa7580b767f449dfe71ae5acde9c27535d5da4840 \
    --hash=sha256:a6b720410350765d3d77c01a5ce098a6c45af446284e45e87a98b8a16e7d564d

Looks like lock file contains index info so this should be possible:

[[package]]
name = "torch"
version = "2.5.1+cpu"
source = { registry = "https://download.pytorch.org/whl/cpu" }

This probably isn't as simple as writing all indexes to requirements file because ordering matters. Maybe there could be a way to manually give it indexes instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement to existing functionalityneeds-designNeeds discussion, investigation, or design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions