uv
uv copied to clipboard
constraint-dependencies setting ignores environment markers
Summary
Hello,
I try to use constraint-dependencies setting to apply constraints for the dependency resolver.
I need to apply constraints because I need to install pyqt5 dependency in a Windows/Linux project (Python>=3.10).
pyqt5 depends on pyqt5-qt5 dependency. Without constraint-dependencies I can't add/install pyqt5 on Windows because there is no pyqt5-qt5 binary distribution on PyPI (This is a mistake by the package maintainers, but nevertheless it is true). The same issue describes here.
So, I have added constraint-dependencies to the pyproject.toml file:
[project]
name = "my-app"
version = "0.1.0"
description = "My app"
readme = "README.md"
requires-python = ">=3.10, <3.14"
dependencies = [
"pyqt5>=5.15.11",
]
[tool.uv]
constraint-dependencies = [
"pyqt5-qt5<=5.15.2; sys_platform == 'win32'"
]
And manifest section has been added to uv.lock file:
[manifest]
constraints = [{ name = "pyqt5-qt5", marker = "sys_platform == 'win32'", specifier = "<=5.15.2" }]
It works fine on Windows, now I can install pyqt5==5.15.11 and pyqt5-qt5==5.15.2.
However, on Linux I would like to install the latest version of pyqt5-qt5 package: pyqt5-qt5==5.15.16 because the latest binary distribution is available for Linux platform. But on Linux I also get pyqt5-qt5==5.15.2. The environment marker "sys_platform == 'win32'" just ignored.
uv even downgrades pyqt5-qt5 version if I add constraint-dependencies after:
❯ uv sync
Using CPython 3.10.17
Creating virtual environment at: .venv
Resolved 4 packages in 0.66ms
Prepared 3 packages in 10.66s
Installed 3 packages in 24ms
+ pyqt5==5.15.11
+ pyqt5-qt5==5.15.16
+ pyqt5-sip==12.17.0
... add constraint-dependencies
❯ uv lock
Resolved 5 packages in 149ms
Updated pyqt5-qt5 v5.15.16 -> v5.15.2, v5.15.16
I think constraint-dependencies setting should take into account environment markers. Especially the fact that the markers are even indicated in the manifest in uv.lock file.
Platform
Windows/Linux
Version
uv 0.7.4
Python version
Python >= 3.10