uv icon indicating copy to clipboard operation
uv copied to clipboard

handle constraints on indirect dependencies

Open raylu opened this issue 1 year ago • 3 comments

if I have this requirements.in

virtualenv

and this requirements.txt

distlib==0.3.8
    # via virtualenv
filelock==3.8.0
    # via virtualenv
platformdirs==2.6.2
    # via virtualenv
virtualenv==20.16.5

then pip-compile requirements.in and uv pip compile requirements.in -o requirements.txt do the same thing (no functional changes to the txt file) so everything is great

if I add this constraints.txt

filelock==3.8.0

and rm requirements.txt, then pip-compile requirements.in -c constraints.txt produces

distlib==0.3.8
    # via virtualenv
filelock==3.8.0
    # via
    #   -c constraints.txt
    #   virtualenv
platformdirs==3.11.0
    # via virtualenv
virtualenv==20.21.1

pip-compile picked the last version of virtualenv that supported the old filelock (20.22.0 requires filelock>=3.11)

however,

$ uv pip compile requirements.in -c constraints.txt -v
[...]
        0.008705s   3ms DEBUG uv_resolver::resolver Searching for a compatible version of virtualenv (*)
        0.008872s   4ms DEBUG uv_resolver::resolver Selecting: virtualenv==20.25.0 (virtualenv-20.25.0-py3-none-any.whl)
   uv_resolver::resolver::get_dependencies package=virtualenv, version=20.25.0
     uv_resolver::resolver::distributions_wait package_id=virtualenv-20.25.0
              0.009378s   0ms DEBUG uv_client::cached_client Found fresh response for: https://files.pythonhosted.org/packages/83/22/54b1180756d2d6194bcafb7425d437c3034c4bff92129c3e1e633079e2c4/virtualenv-20.25.0-py3-none-any.whl
error: There are conflicting versions for `filelock`: `filelock>=3.12.2, <4` does not intersect with `filelock==3.8.0`

raylu avatar Feb 16 '24 18:02 raylu

Interesting, thank you for the clear report!

zanieb avatar Feb 16 '24 18:02 zanieb

Ah yeah, ok, I see the issue here.

charliermarsh avatar Feb 18 '24 02:02 charliermarsh

Have a fix but needs a few more test cases.

charliermarsh avatar Feb 18 '24 02:02 charliermarsh

Hit this as well in my experimentation if you want another real-world case. A one-liner repro:

# Doesn't work
uv pip compile <(printf '%s\n' 'psycopg[c]>=3') -c <(printf '%s\n' 'psycopg==3.1.13' 'psycopg-c==3.1.13')

# Works
uv pip compile <(printf '%s\n' 'psycopg[c]>=3') -o <(printf '%s\n' 'psycopg==3.1.13' 'psycopg-c==3.1.13')

edwardpeek-crown-public avatar Feb 19 '24 05:02 edwardpeek-crown-public

Thank you! I'm hoping to fix it today.

charliermarsh avatar Feb 19 '24 21:02 charliermarsh

Should be fixed in v0.1.7 (out now).

charliermarsh avatar Feb 22 '24 05:02 charliermarsh