uv icon indicating copy to clipboard operation
uv copied to clipboard

Universal resolution can generate un-installable requirements with environments

Open alex opened this issue 1 year ago • 5 comments

(tempenv-564a2572618) ~/.v/tempenv-564a2572618 ❯❯❯ uv version
uv 0.4.0 (Homebrew 2024-08-28)
(tempenv-564a2572618) ~/.v/tempenv-564a2572618 ❯❯❯ cat uv.toml
environments = ["python_version >= '3.10'", "python_version >= '3.8' and python_version < '3.10'", "python_version < '3.8'"]

(tempenv-564a2572618) ~/.v/tempenv-564a2572618 ❯❯❯ echo 'build' | uv pip compile - --universal -p 3.7
warning: The requested Python version 3.7 is not available; 3.12.5 will be used to build dependencies instead.
Resolved 12 packages in 5ms
# This file was autogenerated by uv via the following command:
#    uv pip compile - --universal -p 3.7
build==1.1.1 ; python_full_version < '3.8'
build==1.2.1 ; python_full_version >= '3.8'
colorama==0.4.6 ; os_name == 'nt'
    # via build
importlib-metadata==6.7.0 ; python_full_version < '3.8'
    # via build
importlib-metadata==8.4.0 ; python_full_version < '3.10.2'
    # via build
packaging==24.0 ; python_full_version < '3.8'
    # via build
packaging==24.1 ; python_full_version >= '3.8'
    # via build
pyproject-hooks==1.1.0
    # via build
tomli==2.0.1 ; python_full_version < '3.11'
    # via build
typing-extensions==4.7.1 ; python_full_version < '3.8'
    # via importlib-metadata
zipp==3.15.0 ; python_full_version < '3.8'
    # via importlib-metadata
zipp==3.20.1 ; python_full_version < '3.10.2'
    # via importlib-metadata

The resolutions for importlib-metadata are not usable on Python 3.7, because both of the following match the markers:

importlib-metadata==6.7.0 ; python_full_version < '3.8'
    # via build
importlib-metadata==8.4.0 ; python_full_version < '3.10.2'
    # via build

alex avatar Aug 29 '24 22:08 alex

@BurntSushi - Can you check if this is fixed on your branch?

charliermarsh avatar Aug 29 '24 22:08 charliermarsh

I feel like I should apologize for constantly dragging weird universal resolution issues in, like a cat dragging in mice.

alex avatar Aug 29 '24 22:08 alex

Haha no, it’s good!

charliermarsh avatar Aug 29 '24 22:08 charliermarsh

On main, I get this:

$ echo 'build' | run-uv main -- pip compile - --universal -p 3.7
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
warning: uv is only compatible with Python >=3.8, found Python 3.7.9
Resolved 12 packages in 96ms
# This file was autogenerated by uv via the following command:
#    uv pip compile - --universal -p 3.7
build==1.1.1 ; python_full_version < '3.10'
build==1.2.1 ; python_full_version >= '3.10'
colorama==0.4.6 ; os_name == 'nt'
    # via build
importlib-metadata==6.7.0 ; python_full_version < '3.10'
    # via build
importlib-metadata==8.4.0 ; python_full_version < '3.10.2'
    # via build
packaging==24.0 ; python_full_version < '3.10'
    # via build
packaging==24.1 ; python_full_version >= '3.10'
    # via build
pyproject-hooks==1.1.0
    # via build
tomli==2.0.1 ; python_full_version < '3.11'
    # via build
typing-extensions==4.7.1 ; python_full_version < '3.8'
    # via importlib-metadata
zipp==3.15.0 ; python_full_version < '3.10'
    # via importlib-metadata
zipp==3.20.1 ; python_full_version < '3.10.2'
    # via importlib-metadata

Notice that the markers here are different from yours @alex, but they are still overlapping and thus incorrect.

On my branch, I get:

$ echo 'build' | run-uv pr1 -- pip compile - --universal -p 3.7
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
warning: uv is only compatible with Python >=3.8, found Python 3.7.9
Resolved 12 packages in 38ms
# This file was autogenerated by uv via the following command:
#    uv pip compile - --universal -p 3.7
build==1.1.1 ; python_full_version < '3.10'
build==1.2.1 ; python_full_version >= '3.10'
colorama==0.4.6 ; os_name == 'nt'
    # via build
importlib-metadata==6.7.0 ; python_full_version < '3.10'
    # via build
importlib-metadata==8.4.0 ; python_full_version >= '3.10' and python_full_version < '3.10.2'
    # via build
packaging==24.0 ; python_full_version < '3.10'
    # via build
packaging==24.1 ; python_full_version >= '3.10'
    # via build
pyproject-hooks==1.1.0
    # via build
tomli==2.0.1 ; python_full_version < '3.11'
    # via build
typing-extensions==4.7.1 ; python_full_version < '3.8'
    # via importlib-metadata
zipp==3.15.0 ; python_full_version < '3.10'
    # via importlib-metadata
zipp==3.20.1 ; python_full_version >= '3.10' and python_full_version < '3.10.2'
    # via importlib-metadata

The markers are not overlapping but quite constraining. I haven't dug in to see whether that's correct or not, but these requirements are at least valid.

BurntSushi avatar Aug 29 '24 23:08 BurntSushi

I also get a different warning:

warning: uv is only compatible with Python >=3.8, found Python 3.7.9

Where as @alex's output has:

warning: The requested Python version 3.7 is not available; 3.12.5 will be used to build dependencies instead.

BurntSushi avatar Aug 29 '24 23:08 BurntSushi

I spot checked those markers against the build source, and they look right.

alex avatar Aug 30 '24 11:08 alex

All righty, that means this should be fixed by: https://github.com/astral-sh/uv/pull/6268

BurntSushi avatar Aug 30 '24 11:08 BurntSushi

Great, thanks.

On Fri, Aug 30, 2024 at 7:55 AM Andrew Gallant @.***> wrote:

All righty, that means this should be fixed by: #6268

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

-- All that is necessary for evil to succeed is for good people to do nothing.

alex avatar Aug 30 '24 11:08 alex