Skip to content

Add a minimum macOS version for universal resolution - #23230

Draft
charliermarsh wants to merge 5 commits into
charlie/revert-darwin-release-markersfrom
charlie/minimum-macos-version
Draft

charliermarsh wants to merge 5 commits into
charlie/revert-darwin-release-markersfrom
charlie/minimum-macos-version

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

After reverting #21766, macOS wheel tags contribute platform and architecture coverage during universal resolution. Projects can use required-environments to require macOS wheels, but need a separate way to require support for an older macOS release.

We now accept minimum-macos-version, modeled on minimum-libc-version. uv checks wheel tags against the configured floor and backtracks if a package version lacks compatible wheels and a usable source distribution. The lock retains newer wheels for the selected version so installation can choose the best wheel for the current machine.

[tool.uv]
preview-features = ["minimum-macos-version"]
required-environments = ["sys_platform == 'darwin' and platform_machine == 'arm64'"]
minimum-macos-version = "14.0"

In the two-version fixture, a floor of 14.0 selects a==1 and keeps its macOS 14 and 26 wheels. A floor of 26.0 selects a==2. Both locks round-trip byte for byte and export to requirements.txt and pylock.toml with ordinary platform markers. Changing the floor invalidates the previous resolution.

Comment on lines +1103 to +1106
if minimum_macos_version.is_some_and(|floor| {
!floor.supports(*major, *minor, *arch == BinaryFormat::Arm64)
}) {
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Exclude macOS tags that installation cannot accept

A package without an sdist whose only wheel targets macosx_14_1_arm64 now satisfies required ARM macOS coverage with a 15.0 floor, because supports accepts 14.1 <= 15.0. However, uv-platform-tags::compatible_tags generates only minor-zero tags for macOS 11 and later, so installation rejects that wheel. Universal wheel compatibility does not otherwise filter it. At the merge base, macos_darwin_release returned None for this tag, preventing it from satisfying coverage. Check installer-supported deployment tags before applying the optional floor, including when no floor is configured, and add a regression case.

Comment thread crates/uv/tests/lock/lock.rs Outdated
Comment on lines +44632 to +44636
uv_snapshot!(context.filters(), context.lock().arg("--locked").arg("--index-url").arg(server.index_url()), @"
exit_code: 0 (success)
----- stderr -----
Resolved 2 packages in [TIME]
");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Exercise a floor change against an existing lockfile

Both floor scenarios create a fresh lockfile and then run --locked with unchanged configuration. Consequently, removing the new ValidatedLock comparison would leave these tests passing, despite allowing a macOS-26-only pin to remain locked after lowering the floor to 14. Extend this scenario by changing only the floor to 14.0, snapshotting the --locked failure, and confirming an ordinary lock selects a==1.0.0. The neighboring minimum_libc_backtracks_and_invalidates_lock test demonstrates this pattern.

Comment thread crates/uv-pep508/src/marker/tree.rs Outdated
Comment on lines -1528 to -1529
/// A string-valued marker interpreted as a version within a platform-specific scope.
VersionString(VersionMarkerTree<'a, CanonicalMarkerValueString>),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Remove the unused version-node key abstraction

Deleting VersionString removes the only consumer of VersionMarkerTree with a non-default key type. The generic parameter was justified at the base, but all remaining construction now uses CanonicalMarkerValueVersion; the private fields also prevent callers from constructing alternative instances. Keeping K and its generic method and ordering bounds obscures that invariant. Specialize VersionMarkerTree and its implementations to CanonicalMarkerValueVersion. This cleanup can follow separately.

@charliermarsh
charliermarsh removed this pull request from stack #23232 November 13, 2026 14:22
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from c2a716e to 53e59fe Compare November 13, 2026 14:22
@charliermarsh
charliermarsh changed the base branch from main to charlie/revert-darwin-release-markers November 13, 2026 14:22
environments: Option<SupportedEnvironments>,
required_environments: Option<SupportedEnvironments>,
minimum_libc_version: Option<MinimumLibcVersion>,
minimum_macos_version: Option<MinimumMacosVersion>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Update the existing unknown-field error snapshots

Adding this field changes Serde’s expected-field diagnostic, but show_settings::resolve_config_file and pip_install::invalid_pyproject_toml_option_unknown_field still snapshot the list without minimum-macos-version. Static comparison confirms both lists match the merge-base schema but omit this new field, causing snapshot mismatches at head. Refresh these two existing snapshots alongside the schema change.

@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from 53e59fe to 3bf0297 Compare November 14, 2026 01:52
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from 83b2694 to bf6dc1f Compare November 14, 2026 03:18
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from b557dbc to 07f92e6 Compare November 14, 2026 03:37
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from 07f92e6 to 82b4149 Compare November 14, 2026 03:39
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from 82b4149 to e70e148 Compare November 14, 2026 03:50
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from e70e148 to 4922e1e Compare November 14, 2026 04:01
@charliermarsh
charliermarsh force-pushed the charlie/minimum-macos-version branch from 4922e1e to a92a359 Compare November 14, 2026 04:08
@Andrej730

Copy link
Copy Markdown

That's very useful! I was drafting a feature request about exactly this, even the same option name lol, until noticed a PR.

Currently, it's possible to enforce this using environments, e.g. with platform_release >= '20' and platform_release < '21', but users do need to keep in mind to provide both >= and <, otherwise wheels that do not support 20 might slip in.
And this just bit me - I had platform_release >= '20' and scipy had only scipy-1.18.1-cp315-cp315t-macosx_12_0_arm64.whl (Darwin 21), so it got in, leaving Mac 11 unsupported.

And it's easier to deal with Mac versions than Darwin versions as typically users see Mac version more often in wheel tags (e.g. macosx_11_0_arm64).

This branch was previously deployed

1 inactive deployment
automations — 6a0a066d Deployed Nov 16, 2026 by charliermarsh via review | security / security review #53940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants