uv
uv copied to clipboard
Narrow `requires-python` in forks
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
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.
See also https://github.com/astral-sh/uv/issues/4668 for another variant of this issue.
I can give this a try... Important correctness issue.
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.
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
However, echo 'uv;python_version>="3.8"' | uv pip compile -p 3.7 --universal - requires some more work...
With #4902 merged, it reverted the fix for this issue, so I'm re-opening.