astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
26.9k stars 781 forks source link

Ignore irrelevant platform-specific packages during resolution #9275

Open Vinno97 opened 2 hours ago

Vinno97 commented 2 hours ago

Hi,

I've noticed that uv still tries to resolve packages that are supposed to be irrelevant for the configured environment. I'm working on a server with a private registry where we don't have Darwin packages. When I try to install ipykernel, however, I see it still tries to resolve a Darwin-specific package, which then fails as it isn't available in our registry. Specifically, it's about appnope, which is configured as 'appnope>=0.1.2;platform_system=="Darwin"' in ipykernel' s pyproject.toml.(https://github.com/ipython/ipykernel/blob/8c4901d691b1f309da3b80eefad5af13d7418185/pyproject.toml#L32C6-L32C13)

I'm using uv 0.5.2 on RHEL.

[project]
name = "test-project"
version = "0.1.0"
description = "My test project"
readme = "README.md"

dependencies = [
    "ipykernel ; sys_platform == 'linux'"
]

[tool.uv]
environments = [
    "sys_platform == 'linux'"
]
$ uv lock -v 2>&1 | grep Darwin
DEBUG Solving split (python_full_version == '3.10'and platform_system == 'Darwin' and sys_platform == 'linux') ...
DEBUG Adding transitive dependency for ipykernel==x.x.x: appnope{platform_system == 'Darwin'}*
DEBUG Adding transitive dependency for ipykernel==x.x.x: appnope{platform_system == 'Darwin'}*

I think it might be related to https://github.com/astral-sh/uv/issues/9051#issuecomment-2470334438

charliermarsh commented 2 hours ago

You might want to add something like platform_system == "Linux" to environments? The system doesn't know that platform_system == 'Darwin' and sys_platform == 'linux' are mutually exclusive -- there's nothing in the spec that says they have to be, it's just true in practice.