Skip to content

Commit 4f0f98a

Browse files
committed
Tests markers changing with required-environments
Test case for astral-sh/uv#16824 (comment). Introduces `required-environments` to packse.
1 parent 0b6f246 commit 4f0f98a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name = "markers-change-after-selection"
2+
description = '''A package is first used under a marker that is a subset of the required environments that it fulfills, and then under a marker that is a subset it doesn't fulfill.
3+
4+
See <https://github.com/astral-sh/uv/pull/16824#discussion_r2556176057>
5+
'''
6+
7+
[resolver_options]
8+
universal = true
9+
required_environments = ['sys_platform == "linux"', 'sys_platform == "win32"']
10+
11+
[root]
12+
requires = ["a; sys_platform == 'win32'", "b"]
13+
14+
[expected]
15+
satisfiable = false
16+
17+
[packages.a.versions."1.0.0"]
18+
sdist = false
19+
wheel_tags = [
20+
"cp312-abi3-win_amd64",
21+
]
22+
23+
[packages.b.versions."1.0.0"]
24+
requires = ["a; sys_platform == 'linux'"]

src/packse/scenario.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ class ResolverOptions(msgspec.Struct, forbid_unknown_fields=True):
143143
The Python platform to use for resolution.
144144
"""
145145

146+
required_environments: list[str] | None = None
147+
"""
148+
A list of required platforms, for packages that lack source distributions.
149+
"""
150+
146151
def hash(self) -> str:
147152
"""
148153
Return a hash of the contents
@@ -160,6 +165,9 @@ def hash(self) -> str:
160165
hasher.update(self.universal.to_bytes())
161166
if self.python_platform is not None:
162167
hasher.update(self.python_platform.encode())
168+
if self.required_environments is not None:
169+
for required_environment in self.required_environments:
170+
hasher.update(required_environment.encode())
163171

164172
return hasher.hexdigest()
165173

0 commit comments

Comments
 (0)