uv icon indicating copy to clipboard operation
uv copied to clipboard

Narrow `requires-python` in forks

Open charliermarsh opened this issue 1 year ago • 6 comments

I have some difficulties with numpy (macOS, uv 0.2.18). With a requirements.in

numpy >=1.26; python_version>="3.9"
numpy <1.26; python_version<"3.9"

I cannot univeral-lock for Python >= 3.8:

$ uv pip compile -p 3.8 --universal requirements.in
  × No solution found when resolving dependencies:
  ╰─▶ Because only the following versions of numpy{python_version >= '3.9'} are available:
          numpy{python_version >= '3.9'}<=1.26.0
          numpy{python_version >= '3.9'}==1.26.1
          numpy{python_version >= '3.9'}==1.26.2
          numpy{python_version >= '3.9'}==1.26.3
          numpy{python_version >= '3.9'}==1.26.4
          numpy{python_version >= '3.9'}==2.0.0
      and the requested Python version (3.8) does not satisfy Python>=3.9, we can conclude that any of:
          numpy{python_version >= '3.9'}>=1.26.0,<1.26.2
          numpy{python_version >= '3.9'}>1.26.2,<1.26.3
          numpy{python_version >= '3.9'}>1.26.3,<1.26.4
          numpy{python_version >= '3.9'}>1.26.4,<2.0.0
          numpy{python_version >= '3.9'}>2.0.0
       are incompatible.
      And because the requested Python version (3.8) does not satisfy Python>=3.9 and you require
      numpy{python_version >= '3.9'}>=1.26, we can conclude that the requirements are unsatisfiable.

Originally posted by @davidfritzsche in https://github.com/astral-sh/uv/issues/4640#issuecomment-2198761783

charliermarsh avatar Jun 30 '24 21:06 charliermarsh

My guess is that numpy >=1.26 doesn't support Python 3.8, and we're still trying to lock for your requires-python in that branch. But in theory we could only require requires-python >= 3.9 in the numpy >=1.26 branch.

charliermarsh avatar Jun 30 '24 21:06 charliermarsh

See also https://github.com/astral-sh/uv/issues/4668 for another variant of this issue.

charliermarsh avatar Jun 30 '24 21:06 charliermarsh

I can give this a try... Important correctness issue.

charliermarsh avatar Jul 01 '24 01:07 charliermarsh

This is pretty tricky because we build the VersionMap based on the Python requirement, but now the Python requirement can change in a given fork.

charliermarsh avatar Jul 01 '24 15:07 charliermarsh

I have the NumPy fork working:

# This file was autogenerated by uv via the following command:
#    uv pip compile -p 3.7 --universal req.in
numpy==1.21.6 ; python_version < '3.9'
    # via -r req.in
numpy==2.0.0 ; python_version >= '3.9'
    # via -r req.in

charliermarsh avatar Jul 01 '24 18:07 charliermarsh

However, echo 'uv;python_version>="3.8"' | uv pip compile -p 3.7 --universal - requires some more work...

charliermarsh avatar Jul 01 '24 18:07 charliermarsh

With #4902 merged, it reverted the fix for this issue, so I'm re-opening.

BurntSushi avatar Jul 08 '24 16:07 BurntSushi