Skip to content

Allow the option to make index explicit when using uv add #16291

@BaoNguyen6742

Description

@BaoNguyen6742

Summary

When I add a package using specific index, packages that are installed later give "No solution found when resolving dependencies" error.

Step to reproduce

  1. Running uv add paddlepaddle==3.0.0 --index https://www.paddlepaddle.org.cn/packages/stable/cpu/
    This will create the pyproject.toml file like this
[project]
name = "uv-index"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "paddlepaddle==3.0.0",
]


[tool.uv]
required-environments = [
    "sys_platform == 'win32'" # I add this since numpy 2.3.2 doesn't have a source distribution or wheel when I test on windows.
]

[[tool.uv.index]]
url = "https://www.paddlepaddle.org.cn/packages/stable/cpu/"
  1. Run uv add matplotlib
    This will return the error
× No solution found when resolving dependencies for split (markers: python_full_version >= '3.12' and sys_platform
│ == 'win32'):
╰─▶ Because there are no versions of matplotlib and your project depends on matplotlib, we can conclude that your project's requirements are unsatisfiable.
help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.

There are currently 2 ways to fix this

  1. Run uv add matplotlib with --index-strategy unsafe-first-match or --index-strategy unsafe-best-match
  2. Edit the pyproject.toml in the tool.uv.index section to make the index explicit
    [[tool.uv.index]]
    url = "https://www.paddlepaddle.org.cn/packages/stable/cpu/"
    explicit = true
    

I hope there could be a way to make the index explicit right when you add it so it doesn't affect other package when installing

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions