pubgrub-rs / pubgrub

PubGrub version solving algorithm implemented in Rust
https://pubgrub-rs.github.io/pubgrub/pubgrub/
Mozilla Public License 2.0
337 stars 29 forks source link

Merge custom incompatibility reasons #232

Open konstin opened 3 weeks ago

konstin commented 3 weeks ago

When two versions of a package have the same dependency we merge that into one incompatibility in merge_incompatibility. This allows us to avoid saying "Because a==1.0.0 depends on b>2 and you have b==1 and because a==1.1.0 depends on b>2 and you have b==1, ..." and skip directly to "Because a>=1.0.0 depends on b>2 and you have b==1, ..". Pubgrub should perform the same merging for custom incompatibilities.

Here's a shortened example, the full error message is 200 lines long, most of which are just telling me that tensorflow is missing compatible wheels for a version range:

  × No solution found when resolving dependencies:
  ╰─▶ Because transformers:dev==4.39.0.dev0 depends on transformers==4.39.0.dev0 and
      transformers==4.39.0.dev0 depends on tensorflow>=2.6,<2.16, we can conclude that
      transformers:dev==4.39.0.dev0 depends on tensorflow>=2.6,<2.16. (1)

      Because only the following versions of tensorflow are available:
          tensorflow<=2.6.5
          tensorflow>=2.7.0
      and tensorflow==2.6.0 has no wheels are available with a matching Python ABI, we can conclude that
      any of:
          tensorflow>=2.6.0,<2.6.1
          tensorflow>2.6.5,<2.7.0
       cannot be used.
      And because tensorflow==2.6.1 has no wheels are available with a matching Python ABI and
      tensorflow==2.6.2 has no wheels are available with a matching Python ABI, we can conclude that any of:
          tensorflow>=2.6.0,<2.6.3
          tensorflow>2.6.5,<2.7.0
       cannot be used.
      And because tensorflow==2.6.3 has no wheels are available with a matching Python ABI and
      tensorflow==2.6.4 has no wheels are available with a matching Python ABI, we can conclude that any of:
          tensorflow>=2.6.0,<2.6.5
          tensorflow>2.6.5,<2.7.0
       cannot be used.
      And because tensorflow==2.6.5 has no wheels are available with a matching Python ABI and
      tensorflow==2.7.0 has no wheels are available with a matching Python ABI, we can conclude that
      tensorflow>=2.6.0,<2.7.1 cannot be used.
      And because tensorflow==2.7.1 has no wheels are available with a matching Python ABI and
      tensorflow==2.7.2 has no wheels are available with a matching Python ABI, we can conclude that
      tensorflow>=2.6.0,<2.7.3 cannot be used.
      And because tensorflow==2.7.3 has no wheels are available with a matching Python ABI and
      tensorflow==2.7.4 has no wheels are available with a matching Python ABI, we can conclude that
      tensorflow>=2.6.0,<2.8 cannot be used.
      And because we know from (1) that transformers:dev==4.39.0.dev0 depends on tensorflow>=2.6,<2.16, we
      can conclude that transformers:dev==4.39.0.dev0 depends on tensorflow>=2.8,<2.16.
      And because transformers==4.39.0.dev0 depends on tensorflow<2.8 and transformers:dev==4.39.0.dev0, we
      can conclude that transformers==4.39.0.dev0 cannot be used.
      And because only transformers==4.39.0.dev0 is available and transformers 

I can create a reproducible example if it's required.

Ref https://github.com/astral-sh/uv/issues/2519