Skip to content

Use uv's environments settings to pick default targets #71

Closed

Description

@patrickballard

uv projects can declare which platforms they support in pyproject.toml:

[tool.uv]
environments = ["sys_platform == 'linux'", "sys_platform == 'darwin'"]
required-environments = ["sys_platform == 'linux' and platform_machine == 'aarch64'"]

required-environments in particular is exactly "the platforms I ship to": uv will refuse to lock if a package has no wheel for one of them. wheelgap could use these as default targets when -t and [tool.wheelgap] targets aren't set, so a uv project gets the right check with no configuration.

What to do

  • Read [tool.uv] required-environments (and maybe environments) in cli.py next to load_config.
  • Map each marker expression to wheelgap targets. A good approach is to evaluate each one against every target's marker_env (see Target.marker_env in src/wheelgap/targets.py) and keep the targets where it's true.
  • Precedence: -t, then --dockerfile, then [tool.wheelgap], then [tool.uv], then the built-in defaults.
  • Note in the output where the targets came from, since this is implicit.
  • Tests with a few marker combinations.

Also worth a look: README "How it works" mentions environments-restricted lockfiles, which this would make smoother.

Activity

  1. added
    enhancement
    help wanted
    on Nov 9, 2026
  2. patrickballard commented on Nov 9, 2026

    @patrickballard
    CollaboratorAuthor

    A good first step

    Read [tool.uv] required-environments only. Add a function next to load_config in src/wheelgap/cli.py that keeps the platforms in NATIVE_PLATFORMS (targets.py) where marker_holds(marker, target) (check.py) is true for any of the markers, using the run's Python. In main(), use it only when args.target or config.get("targets") is empty (that already covers -t, --dockerfile and [tool.wheelgap]), and print a note on stderr saying where the targets came from. Markers can't tell glibc from musl, so say how you treat musl-*.

    Not in this PR: environments, mobile or Pyodide.

    Tests in tests/test_cli.py with fake_pypi and a pyproject.toml in tmp_path: Linux only, platform_machine == 'aarch64', two markers, -t still winning, and a marker that matches no target.

    (Reply assisted by Claude.)

  3. Swarneil1905 commented on Nov 10, 2026

    @Swarneil1905
    Contributor

    Hi @patrickballard, I'd like to work on this issue. Could you assign it to me?

  4. patrickballard commented on Nov 10, 2026

    @patrickballard
    CollaboratorAuthor

    Go for it, @Swarneil1905, and thanks for asking! Your request is what got us to start assigning issues, so this is the first one under the new rule.

    I've assigned this to you. Assignments hold for 18 hours: open a PR (a draft is fine) by 21:30 UTC on 10 Nov to keep it. If there's no PR by then, the issue opens up again and the first PR to arrive is the one we merge. The "good first step" comment above has the file and function pointers to start from.

    (Reply assisted by Claude.)

  5. added a commit that references this issue on Nov 10, 2026
    ff0a3e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions