Skip to content

Commit

Permalink
Allow scenarios to set a Python platform (#233)
Browse files Browse the repository at this point in the history
## Summary

In uv, we're starting to show "compatible tags" in error messages. If we
don't set the Python platform, then the displayed tag will vary based on
the host machine.
  • Loading branch information
charliermarsh authored Jan 12, 2025
1 parent 9d1d10e commit fbc0ec3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions scenarios/wheels/no-sdist-no-wheels-with-matching-abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ satisfiable = false
[packages.a.versions."1.0.0"]
wheel_tags = ["py3-MMMMMM-any"]
sdist = false

[resolver_options]
python_platform = "x86_64-manylinux2014"
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ satisfiable = false
[packages.a.versions."1.0.0"]
wheel_tags = ["py3-none-macosx_10_0_ppc64"]
sdist = false

[resolver_options]
python_platform = "x86_64-manylinux2014"
3 changes: 3 additions & 0 deletions scenarios/wheels/no-sdist-no-wheels-with-matching-python.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ satisfiable = false
[packages.a.versions."1.0.0"]
wheel_tags = ["jy27-none-any"]
sdist = false

[resolver_options]
python_platform = "x86_64-manylinux2014"
9 changes: 9 additions & 0 deletions src/packse/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class ResolverOptions(msgspec.Struct, forbid_unknown_fields=True):
non-overlapping marker expressions.
"""

python_platform: str | None = None
"""
The Python platform to use for resolution.
"""

def hash(self) -> str:
"""
Return a hash of the contents
Expand All @@ -152,6 +157,10 @@ def hash(self) -> str:
hasher.update(no_binary.encode())
for no_build in self.no_build:
hasher.update(no_build.encode())
if self.universal is not None:
hasher.update(self.universal.to_bytes())
if self.python_platform is not None:
hasher.update(self.python_platform.encode())

return hasher.hexdigest()

Expand Down
12 changes: 8 additions & 4 deletions tests/__snapshots__/test_inspect.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
"prereleases": false,
"no_build": [],
"no_binary": [],
"universal": false
"universal": false,
"python_platform": null
},
"template": "package",
"description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.",
Expand Down Expand Up @@ -251,7 +252,8 @@
"prereleases": false,
"no_build": [],
"no_binary": [],
"universal": false
"universal": false,
"python_platform": null
},
"template": "package",
"description": "This is an example scenario, in which the user depends on a single package `a` which requires `b`.",
Expand Down Expand Up @@ -415,7 +417,8 @@
"prereleases": false,
"no_build": [],
"no_binary": [],
"universal": false
"universal": false,
"python_platform": null
},
"template": "package",
"description": "This is an example scenario written in TOML, in which the user depends on a single package `a` which requires `b`.",
Expand Down Expand Up @@ -552,7 +555,8 @@
"prereleases": false,
"no_build": [],
"no_binary": [],
"universal": false
"universal": false,
"python_platform": null
},
"template": "package",
"description": "This is an example scenario written in YAML, in which the user depends on a single package `a` which requires `b`.",
Expand Down

0 comments on commit fbc0ec3

Please sign in to comment.