-
Notifications
You must be signed in to change notification settings - Fork 943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specifying different dependency versions for different platforms #9515
Comments
I'd probably suggest something like this: [build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"torch>=<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"torch>=2.3; sys_platform != 'darwin' or platform_machine != 'x86_64'",
] |
Thanks @charliermarsh. dependencies = [
"torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"torch>=2.3; sys_platform != 'darwin' or platform_machine != 'x86_64'",
] However, our library is designed to support PyTorch versions greater than 1.13 across all platforms. When we specify the dependencies as follows: dependencies = [
"torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"torch>=1.13; sys_platform != 'darwin' or platform_machine != 'x86_64'",
] it still results in all platforms installing version 2.2.2. |
Yeah, that's intended. If you provide constraints that can be solved with fewer total versions, uv will prefer to use fewer versions. In that case, 2.2.2 satisfies both of your constraints, so uv chooses 2.2.2 rather than creating a more heterogenous environment (i.e., an environment that's less consistent across platforms). If you're looking for a change in that behavior, follow #8686 and #7190. But uv is doing the intended thing given those constraints. |
Thank you, @charliermarsh. I've just noticed that this behavior doesn't align with the pip interface. When I execute dependencies = [
"torch>1.13,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",
"torch>=1.13; sys_platform != 'darwin' or platform_machine != 'x86_64'",
] it successfully installs the latest version of PyTorch on linux. Could we have other uv commands, such as |
Hello,
I've encountered an issue while trying to specify different versions of PyTorch for Intel macOS in my project.
Here is a minimal
pyproject.toml
that shows the issue:I’m trying to make sure that Intel macOS (darwin_x86_64) uses a specific version of PyTorch as there are no new wheels available for versions 2.3 and above. But the dependency resolver seems to apply this constraint universally when generating the lock file, resulting in version 2.2.2 being installed across all platforms.
Is there a better way to set these conditions, maybe in a
tool.uv
section? Any tips would be super helpful!Related to #8358.
The text was updated successfully, but these errors were encountered: