Repository navigation
Description
Question
Hi! I wanted to enforce some environments to always be satisfied for my project and initially I've added them to required-environments. A bit of a problem I've noticed that it doesn't prevent unrelated platform wheels from appearing the lockfile, so I've also added the same environments to environments. And then I've noticed that removing required-environments still keeps environments required.
Steps to reproduce:
uv init .uv add --no-sync pywin32
3, Addtool.uvbelow.
[tool.uv]
# Require that the package is available on the following platforms:
environments = [
# macOS on Apple Silicon (ARM)
"sys_platform == 'darwin' and platform_machine == 'arm64'",
# Linux on x86_64 (Intel/AMD)
"sys_platform == 'linux' and platform_machine == 'x86_64'",
# Windows on x86_64 (Intel/AMD)
"sys_platform == 'win32' and platform_machine == 'AMD64'",
]
uv lock.
Results in
error: No solution found when resolving dependencies for split (markers: platform_machine == 'arm64' and sys_platform == 'darwin')
cause: Because pywin32==312 has no `platform_machine == 'arm64' and sys_platform == 'darwin'`-compatible wheels and only pywin32<=312 is available, we can conclude that pywin32>=312 cannot be used.
And because your project depends on pywin32>=312, we can conclude that your project's requirements are unsatisfiable.
So effectively just using environments is enough to enforce required environments. Is this expected? This does seems to contract the docs (https://docs.astral.sh/uv/reference/settings/#required-environments):
While the environments setting limits the set of environments that uv will consider when resolving dependencies, required-environments expands the set of platforms that uv must support when resolving dependencies.
For example, environments = ["sys_platform == 'darwin'"] would limit uv to solving for macOS (and ignoring Linux and Windows). On the other hand, required-environments = ["sys_platform == 'darwin'"] would require that any package without a source distribution include a wheel for macOS in order to be installable.
Which sounds like adding environments shouldn't make resolution fail.
Platform
Version
uv 0.13.8
Activity
abhi478jeetur-rgb commentedon Nov 17, 2026
Yes, this is expected — I reproduced your exact steps on uv 0.13.8 and got the same error, and the failure comes from the dependency being unconditional, not from
environmentssecretly acting likerequired-environments.environmentsdeclares the platforms the project has to install on, and every dependency has to resolve in each of those forks. pywin32 ships Windows-only wheels and no sdist, so the darwin/arm64 fork has nothing it can install — that's what the error is saying. The docs line you quoted is about which platforms are considered:environmentsnarrows that set,required-environmentswidens the wheel-coverage requirement. Neither one exempts a package from a platform you listed.One thing worth knowing:
required-environmentson its own doesn't get you out of this either. I tried the same three platforms underrequired-environmentsinstead ofenvironments, and it fails with the same cause (different fork label,sys_platform != 'win32'). With neither setting the lock succeeds, because then a package only needs at least one compatible wheel somewhere.The fix is to scope the dependency to the platform it actually supports:
With that marker,
uv locksucceeds under bothenvironmentsandrequired-environments, and the lockfile records pywin32 with thesys_platform == 'win32'marker. If your intent was "make sure these platforms are covered" rather than "support only these",required-environmentsplus the marker is the combination you want.