Skip to content

Support for multiple versions of the same package in different optional dependencies #8024

@gbaudino

Description

@gbaudino

Summary

I'm working on a project that requires different versions of the same package for two separate environments. For example, I need numpy==2.1.2 for one environment and numpy==2.0.0 for another. However, UV does not seem to support this scenario, as it results in dependency resolution conflicts.

Expected behavior

Is there a way to specify different versions of the same package in separate optional dependencies without causing conflicts?

Example

Here is a simplified example of my pyproject.toml file:

dependencies = [
    "some-shared-lib",
]

[project.optional-dependencies]
project1 = [
    "numpy==2.1.2",
    "some-other-lib",
]

project2 = [
    "numpy==2.0.0",
    "some-other-lib",
]

Issue

When I run uv sync with this configuration, I get No solution found when resolving dependencies for split (python_full_version == '3.11.*') error.

My current uv version is 0.4.19 installed from brew.

Why this would be useful

In cases like our repository, where different subprojects require different versions of the same package, not having this feature forces us to create a separate project for each subproject within the same repository. This approach is less convenient compared to having distinct optional dependencies that are exclusive to each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions